Module jls.net.http.HttpHandler

Base HTTP handler class.

An HTTP handler provides a way to deal with an HTTP request. Basicaly it consists in a function that will be called when an HTTP request has been received but before the request body was consumed.

Usage:

    local handler = HttpHandler:new(function(self, httpExchange)
      local response = httpExchange:getResponse()
      response:setBody('It works !')
    end)
    

Class HttpHandler

HttpHandler:new ([fn]) Creates an HTTP handler.
httpHandler:handle (httpExchange) Handles the request for the specified exchange.
httpHandler:close () Closes this request handler.


Class HttpHandler

A HttpHandler class. The handler is called when the request headers are available.
HttpHandler:new ([fn])
Creates an HTTP handler.

Parameters:

  • fn function a function that will handle the HTTP exchange (optional)
httpHandler:handle (httpExchange)
Handles the request for the specified exchange.

Parameters:

  • httpExchange HttpExchange the HTTP exchange to handle

Returns:

    jls.lang.Promise a optional promise that resolves once the response is completed.
httpHandler:close ()
Closes this request handler. Do nothing by default. Must support to be called multiple times.
generated by LDoc 1.4.6 Last updated 2022-01-22 16:32:56