Copyright | (c) Alexey Radkov 2016-2019 |
---|---|
License | BSD-style |
Maintainer | alexey.radkov@gmail.com |
Stability | stable |
Portability | non-portable (requires POSIX) |
Safe Haskell | None |
Language | Haskell2010 |
Export regular haskell functions for using in directives of nginx-haskell-module.
Synopsis
- type ContentHandlerResult = (ByteString, ByteString, Int)
- type UnsafeContentHandlerResult = (ByteString, ByteString, Int)
- ngxExportSS :: Name -> Q [Dec]
- ngxExportSSS :: Name -> Q [Dec]
- ngxExportSLS :: Name -> Q [Dec]
- ngxExportBS :: Name -> Q [Dec]
- ngxExportBSS :: Name -> Q [Dec]
- ngxExportBLS :: Name -> Q [Dec]
- ngxExportYY :: Name -> Q [Dec]
- ngxExportBY :: Name -> Q [Dec]
- ngxExportIOYY :: Name -> Q [Dec]
- ngxExportAsyncIOYY :: Name -> Q [Dec]
- ngxExportAsyncOnReqBody :: Name -> Q [Dec]
- ngxExportServiceIOYY :: Name -> Q [Dec]
- ngxExportHandler :: Name -> Q [Dec]
- ngxExportDefHandler :: Name -> Q [Dec]
- ngxExportUnsafeHandler :: Name -> Q [Dec]
- ngxExportAsyncHandler :: Name -> Q [Dec]
- ngxExportAsyncHandlerOnReqBody :: Name -> Q [Dec]
- ngxExportServiceHook :: Name -> Q [Dec]
- ngxCyclePtr :: IO (Ptr ())
- ngxUpstreamMainConfPtr :: IO (Ptr ())
- ngxCachedTimePtr :: IO (Ptr (Ptr ()))
- newtype TerminateWorkerProcess = TerminateWorkerProcess String
- newtype RestartWorkerProcess = RestartWorkerProcess String
- data FinalizeHTTPRequest = FinalizeHTTPRequest Int (Maybe String)
- newtype CInt = CInt Int32
- newtype CUInt = CUInt Word32
Type declarations
type ContentHandlerResult = (ByteString, ByteString, Int) Source #
The 3-tuple contains (content, content-type, HTTP-status).
type UnsafeContentHandlerResult = (ByteString, ByteString, Int) Source #
The 3-tuple contains (content, content-type, HTTP-status).
Both the content and the content-type are supposed to be referring to low-level string literals that do not need to be freed upon an HTTP request termination and must not be garbage-collected in the Haskell RTS.
Exporters
Synchronous handlers
Asynchronous handlers and services
ngxExportAsyncOnReqBody :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->ByteString
->IO
ByteString
for using in directive haskell_run_async_on_request_body.
The first argument of the exported function contains buffers of the client request body.
ngxExportServiceIOYY :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->Bool
->IO
ByteString
for using in directives haskell_run_service and haskell_service_var_update_callback.
The boolean argument of the exported function marks that the service is being run for the first time.
Content handlers
ngxExportHandler :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->ContentHandlerResult
for using in directives haskell_content and haskell_static_content.
ngxExportDefHandler :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->ByteString
for using in directives haskell_content and haskell_static_content.
ngxExportUnsafeHandler :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->UnsafeContentHandlerResult
for using in directive haskell_unsafe_content.
ngxExportAsyncHandler :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->IO
ContentHandlerResult
for using in directive haskell_async_content.
ngxExportAsyncHandlerOnReqBody :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->ByteString
->IO
ContentHandlerResult
for using in directive haskell_async_content_on_request_body.
The first argument of the exported function contains buffers of the client request body.
Service hooks
ngxExportServiceHook :: Name -> Q [Dec] Source #
Exports a function of type
ByteString
->IO
ByteString
for using in directives haskell_service_hook and haskell_service_update_hook.
Opaque pointers to Nginx global objects
ngxCyclePtr :: IO (Ptr ()) Source #
Returns an opaque pointer to the Nginx cycle object for using it in C plugins.
Actual type of the returned pointer is
ngx_cycle_t *
(value of argument cycle in the worker's initialization function).
ngxUpstreamMainConfPtr :: IO (Ptr ()) Source #
Returns an opaque pointer to the Nginx upstream main configuration for using it in C plugins.
Actual type of the returned pointer is
ngx_http_upstream_main_conf_t *
(value of expression
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_upstream_module)
in the worker's initialization function).
ngxCachedTimePtr :: IO (Ptr (Ptr ())) Source #
Returns an opaque pointer to the Nginx cached time object for using it in C plugins.
Actual type of the returned pointer is
volatile ngx_time_t **
(address of the Nginx global variable ngx_cached_time).
Accessing Nginx core functionality from Haskell handlers
newtype TerminateWorkerProcess Source #
Terminates the worker process.
Being thrown from a service, this exception makes Nginx log the supplied message and terminate the worker process without respawning. This can be useful when the service is unable to read its configuration from the Nginx configuration script or to perform an important initialization action.
Since: 1.6.2
TerminateWorkerProcess String | Contains the message to log |
Instances
Show TerminateWorkerProcess Source # | |
Defined in NgxExport showsPrec :: Int -> TerminateWorkerProcess -> ShowS # show :: TerminateWorkerProcess -> String # showList :: [TerminateWorkerProcess] -> ShowS # | |
Exception TerminateWorkerProcess Source # | |
Defined in NgxExport |
newtype RestartWorkerProcess Source #
Restarts the worker process.
The same as TerminateWorkerProcess
, except that a new worker process shall
be spawned by the Nginx master process in place of the current one.
Since: 1.6.3
RestartWorkerProcess String | Contains the message to log |
Instances
Show RestartWorkerProcess Source # | |
Defined in NgxExport showsPrec :: Int -> RestartWorkerProcess -> ShowS # show :: RestartWorkerProcess -> String # showList :: [RestartWorkerProcess] -> ShowS # | |
Exception RestartWorkerProcess Source # | |
Defined in NgxExport |
data FinalizeHTTPRequest Source #
Finalizes the HTTP request.
Being thrown from an asynchronous variable handler, this exception makes Nginx finalize the current HTTP request with the supplied HTTP status and an optional body. If the body is Nothing then the response will be styled by the Nginx core.
Since: 1.6.3
FinalizeHTTPRequest Int (Maybe String) | Contains HTTP status and body |
Instances
Show FinalizeHTTPRequest Source # | |
Defined in NgxExport showsPrec :: Int -> FinalizeHTTPRequest -> ShowS # show :: FinalizeHTTPRequest -> String # showList :: [FinalizeHTTPRequest] -> ShowS # | |
Exception FinalizeHTTPRequest Source # | |
Defined in NgxExport |
Re-exported data constructors from Foreign.C
Re-exports are needed by exporters for marshalling in foreign calls.
Haskell type representing the C int
type.
Instances
Bounded CInt | |
Enum CInt | |
Eq CInt | |
Integral CInt | |
Num CInt | |
Ord CInt | |
Read CInt | |
Real CInt | |
Defined in Foreign.C.Types toRational :: CInt -> Rational # | |
Show CInt | |
Storable CInt | |
Defined in Foreign.C.Types | |
Bits CInt | |
Defined in Foreign.C.Types (.&.) :: CInt -> CInt -> CInt # (.|.) :: CInt -> CInt -> CInt # complement :: CInt -> CInt # shift :: CInt -> Int -> CInt # rotate :: CInt -> Int -> CInt # setBit :: CInt -> Int -> CInt # clearBit :: CInt -> Int -> CInt # complementBit :: CInt -> Int -> CInt # testBit :: CInt -> Int -> Bool # bitSizeMaybe :: CInt -> Maybe Int # shiftL :: CInt -> Int -> CInt # unsafeShiftL :: CInt -> Int -> CInt # shiftR :: CInt -> Int -> CInt # unsafeShiftR :: CInt -> Int -> CInt # rotateL :: CInt -> Int -> CInt # | |
FiniteBits CInt | |
Defined in Foreign.C.Types | |
NFData CInt | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq |
Haskell type representing the C unsigned int
type.
Instances
Bounded CUInt | |
Enum CUInt | |
Eq CUInt | |
Integral CUInt | |
Num CUInt | |
Ord CUInt | |
Read CUInt | |
Real CUInt | |
Defined in Foreign.C.Types toRational :: CUInt -> Rational # | |
Show CUInt | |
Storable CUInt | |
Bits CUInt | |
Defined in Foreign.C.Types (.&.) :: CUInt -> CUInt -> CUInt # (.|.) :: CUInt -> CUInt -> CUInt # xor :: CUInt -> CUInt -> CUInt # complement :: CUInt -> CUInt # shift :: CUInt -> Int -> CUInt # rotate :: CUInt -> Int -> CUInt # setBit :: CUInt -> Int -> CUInt # clearBit :: CUInt -> Int -> CUInt # complementBit :: CUInt -> Int -> CUInt # testBit :: CUInt -> Int -> Bool # bitSizeMaybe :: CUInt -> Maybe Int # shiftL :: CUInt -> Int -> CUInt # unsafeShiftL :: CUInt -> Int -> CUInt # shiftR :: CUInt -> Int -> CUInt # unsafeShiftR :: CUInt -> Int -> CUInt # rotateL :: CUInt -> Int -> CUInt # | |
FiniteBits CUInt | |
Defined in Foreign.C.Types finiteBitSize :: CUInt -> Int # countLeadingZeros :: CUInt -> Int # countTrailingZeros :: CUInt -> Int # | |
NFData CUInt | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq |