Sugar extract web request parameter from common sources for you to access from espresso handler.
By default Sugar ship three extractors, the query string extractor,
the json body extractor and the form body one. You can implement the
Extractor
interface and implement your own extractor.
Sugar acts as a middleware for Espresso application. Simply wrap your
espresso application in new Sugar(espresso)
then you will be able to
access extracted parameters in handler function:
// Works for get request like http://hostname/?a=helloworld
// or json post request with body {"a": "helloworld"}
// or form post ...
var espresso = (req) -> {
var a = Sugar.extension(req).get("a");
return Response.of(200).body(a);
}
Implement your own Extractor
class to extractor more data from
request and access it in the Sugar's way.
See license