- java.lang.Object
-
- io.helidon.media.jsonp.server.JsonSupport
-
- All Implemented Interfaces:
Handler,Service,BiConsumer<ServerRequest,ServerResponse>
public final class JsonSupport extends Object implements Service, Handler
It provides contains JSON-P (javax.json) support forWebServer'sRouting. It is intended to provide readers and writers forjavax.jsonobjects such asJsonObjectorJsonArray. If registered on theWeb ServerRouting, then allHandlerscan useServerRequest.content().as(...)andServerResponse.send()withJSONobjects.Get Instance
Use factory methodscreate()orcreate(io.helidon.media.jsonp.common.JsonProcessing)to acquire an instance.Usage with Routing
JsonSupportshould be registered on the routing before any business logic handlers.
Instance behaves also as a routing filter. It means that it can be registered on any routing rule (for example HTTP method) and then it can be used in following handlers with compatible rules.Routing.builder() .register(JsonSupport.create()) .etc.... // Business logic related handlers// Register JsonSupport only for POST of 'foo' Routing.builder() .post("/foo/{}", JsonSupport.create()) .post("/foo/bar", ...) // It can use JSON structures .get("/foo/bar", ...); // It can NOT use JSON structures- See Also:
Routing,JsonStructure,JsonpBodyReader,JsonpBodyWriter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.helidon.webserver.Handler
Handler.EntityHandler<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ServerRequest request, ServerResponse response)static JsonSupportcreate()Returns a singleton instance of JsonSupport with default configuration.static JsonSupportcreate(JsonProcessing processing)Create a JsonSupport with customized processing configuration.voidupdate(Routing.Rules rules)UpdatesRouting.Ruleswithhandlersrepresenting this service.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.function.BiConsumer
andThen
-
-
-
-
Method Detail
-
update
public void update(Routing.Rules rules)
Description copied from interface:ServiceUpdatesRouting.Ruleswithhandlersrepresenting this service.
-
accept
public void accept(ServerRequest request, ServerResponse response)
Description copied from interface:Handler- Specified by:
acceptin interfaceBiConsumer<ServerRequest,ServerResponse>- Specified by:
acceptin interfaceHandler- Parameters:
request- an HTTP server request.response- an HTTP server response.
-
create
public static JsonSupport create()
Returns a singleton instance of JsonSupport with default configuration.Use
create(io.helidon.media.jsonp.common.JsonProcessing)method to create a new instance with specific configuration.- Returns:
- a singleton instance with default configuration
-
create
public static JsonSupport create(JsonProcessing processing)
Create a JsonSupport with customized processing configuration.- Parameters:
processing- processing to get JSON-P readers and writers- Returns:
- JsonSupport to register with web server
- See Also:
JsonProcessing.builder()
-
-