This module contains some high level wrapper to build Nginx module with nginx-c-function
For low level wrapper, please import ngxcmod/raw
Consts
CONTENT_TYPE_PLAINTEXT = "text/plain"
CONTENT_TYPE_HTML = "text/html; charset=utf-8"
CONTENT_TYPE_JSON = "application/json"
CONTENT_TYPE_JSONP = "application/javascript"
CONTENT_TYPE_XFORMENCODED = "application/x-www-form-urlencoded"
Templates
template log(ctx: Context; level: LOG_LEVEL; msg: string)
- sends log message to Nginx
template getHeader(ctx: Context; key: string): string
- Returns the values associated with the given key
template getQueryParam(ctx: Context; key: string): string
- Returns the values associated with the given key
template getArgs(ctx: Context): string
- get the uri args
template getBody(ctx: Context): tuple[p: string, size: int]
- Get request body, and its length
template getBodyAsStr(ctx: Context): string
- Get request body, ctx.req_body may not terminated with NULL, use it as yourown risk
template getSharedMem(ctx: Context): pointer
- returns pointer to shared memory
template response(ctx: Context; statusCode: uint; statusLine: string; contentType: string; content: string)
- Write response to client
template cacheGet(sharedMem: pointer; key: string): pointer
template cachePut(sharedMem: pointer; key: string; value: pointer): pointer
template cacheNew(sharedMem: pointer; key: string; size: int): pointer
template cacheRemove(sharedMem: pointer; key: string; size: int): pointer