A Processor is a function that is applied with the HttpRequest and returns a Future of a HttpResponse.
A Processor is a function that is applied with the HttpRequest and returns a Future of a HttpResponse. The HttpResponse (response) that is returned will be returned to the user if the status code is non zero.
The function returns a response, rather than a modified HttpRequest, because we want to allow the DSL to return responses that do not require the exchange to be wrapped. Eg,
someprocessor { req => "literal string" }
If the Processor was HttpRequest => HttpRequest (or some other container class) then the final processor would need to be something like:
someprocessor { req => req withResponse "literal string" }
Which is just ugly, and more hassle.
Adds a processor that adds a header with the given name and value to the response.
Adds a processor that adds a header with the given name and value to the response. This is an alternative way of doing response.withHeader(h, v) on the response object.
Processor that requires the request to identify itself as an ajax request by incuding the X-Requested-With header set to value "XMLRequest"
Processor that requires the request to identify itself as an ajax request by incuding the X-Requested-With header set to value "XMLRequest"
This processor can be used when the last processor in an endpoint pipeline uses multiple parameters and you don't like the param => req => handler syntax.
This processor can be used when the last processor in an endpoint pipeline uses multiple parameters and you don't like the param => req => handler syntax.
Eg,
get("myurl") { cookie("session") { sessionId => req => s"My sessionId is " + sessionId } } can be re-written as get("myurl") { cookie("session") { sessionId => { complete { req => s"My sessionId is $sessionId [$req]" } } }
A processor that sets the content type of the request.
A processor that sets the content type of the request.
Adds a processor to the pipeline that requires the request to have a cookie with the given name.
Adds a processor to the pipeline that requires the request to have a cookie with the given name. If the request does not contain the cookie then processing will skip to the next endpoint. The processor does not inspect the cookie value.
the cookie name that must be present on the request
this
A Processor that requests the removal of a cookie on the client side, by setting a cookie with the given name to a nonsense value, and a max age of -1.
A Processor that requests the removal of a cookie on the client side, by setting a cookie with the given name to a nonsense value, and a max age of -1.
Define error handling that will be chained to the existing error handlers.
Define error handling that will be chained to the existing error handlers. Error handlers are invoked as a stack, so the last registered erorr handler will be the first invoked. If a particular error handler does not handle the given exceptions, then the next error handler in the stack will be invoked until the default error handling is reached. Only one error handler per module can be registered.
Adds a filter that will run before each of the endpoints defined in this module.
Adds a filter that will run before each of the endpoints defined in this module.
Filters are only executed once per request, so if an endpoint skips to another endpoint, the filter will not be re-executed.
Note: HttpModule specific filters (ie, filters added here) will be executed after server-wide specific filters (those registered with the endpoint container).
Adds a processor to the pipeline that requires the request to have a header with the given name and value If the request does not contain the header then processing will skip to the next endpoint.
Adds a processor to the pipeline that requires the request to have a header with the given name and value If the request does not contain the header then processing will skip to the next endpoint.
the header that must be present on the request
this
Adds a processor to the pipeline that requires the request to have a header with the given name.
Adds a processor to the pipeline that requires the request to have a header with the given name. If the request does not contain the header then processing will skip to the next endpoint.
the header that must be present on the request
this
A Processor that only handles the request if the request is HTTP / un-secured
A Processor that only handles the request if the request is HTTP / un-secured
A Processor that only handles the request if the request is HTTPS / secure
A Processor that only handles the request if the request is HTTPS / secure
Processes request only if the ipaddress in the request matches the given regex.
Processes request only if the ipaddress in the request matches the given regex.
Creates a Response, which is a 200 OK, with the given entity set as the payload with the given content-type.
Creates a Response, which is a 200 OK, with the given entity set as the payload with the given content-type.
Creates a Response, which is a 200 OK, with the given entity set as the payload with the given content-type.
Creates a Response, which is a 200 OK, with the given entity set as the payload with the given content-type.
Creaes a 200 ok response with the entity set to the given value, and the content type inferred.
Creaes a 200 ok response with the entity set to the given value, and the content type inferred.
A Processor that extracts the scheme from the request and makes it available in the inner processor.
A Processor that extracts the scheme from the request and makes it available in the inner processor.
the inner processor function that accepts a String, which is the schema value.
Extracts the current session.
Extracts the current session. If no such session exists then a 500 Internal Server Error response will be generated and returned.
Extracts the current session as an Option.
Extracts the current session as an Option. If no session exists then the value will be a None. This method will not create a session if one does not already exist.
Extracts a property from the session.
Extracts a property from the session. If the session does not exist then the endpoint will return a 500 Internal Service Error. If the property does not exist in the session then the endpoint will return a 500 Interal Service Error
Extracts an optional property from the session.
Extracts an optional property from the session. If the session does not exist then the endpoint will return a 500 Internal Service Error. If the property does not exist then the nested processor will be invoked with a None.
Builds a Response with the status code set to a HttpStatus which has the value of the given int.
Builds a Response with the status code set to a HttpStatus which has the value of the given int.
Eg, status(200) will return a Response of 200
Builds a Response with the status code set the given HttpStatus
Builds a Response with the status code set the given HttpStatus
Eg, status(HttpStatus.OK) will return a Response of 200
The regex to match on the user agent
The regex to match on the user agent
(Since version 1.13.3) prefer hasQueryParam
(Since version 1.13.3) prefer queryParam
A trait that provides the entry point to the DSL.
Classes / objects that contain the endpoints for your application should extend this trait and call the get/post/delete/etc methods, providing the path to match on and the function chain.