Module jls.net.http.HttpContext
The HttpContext class maps a path to a handler.
Class HttpContext
HttpContext:new (path[, handler[, attributes]]) | Creates a new Context. |
httpContext:getPath () | Returns the context path. |
httpContext:setPathReplacement (repl) | Sets the path replacement, default is '%1'. |
httpContext:getArguments (path) | Returns the captured values of the specified path. |
httpContext:replacePath (path) | Returns the target path of the specified path. |
Class HttpContext
The HttpContext class maps a path to a handler.
The HttpContext is used by the HttpServer.
- HttpContext:new (path[, handler[, attributes]])
-
Creates a new Context.
The handler will be called when the request headers have been received if specified.
The handler will be called when the body has been received if no response has been set.
Parameters:
- path string the context path
- handler function the context handler the function takes one argument which is an HttpExchange. (optional)
- attributes table the optional context attributes (optional)
- httpContext:getPath ()
-
Returns the context path.
Returns:
-
string
the context path.
- httpContext:setPathReplacement (repl)
-
Sets the path replacement, default is '%1'.
Parameters:
- repl the replacement compliant with the string.gsub function
Returns:
-
this context
- httpContext:getArguments (path)
-
Returns the captured values of the specified path.
Parameters:
- path
Returns:
-
string
the first captured value, nil if there is no captured value.
- httpContext:replacePath (path)
-
Returns the target path of the specified path.
It consists in the first captured value, or the
Parameters:
- path
Returns:
-
string
the first captured value, nil if there is no captured value.