- java.lang.Object
-
- aeonics.template.Item<Endpoint.Type>
-
- aeonics.http.Endpoint
-
- aeonics.http.Endpoint.Rest
-
- Enclosing class:
- Endpoint
public abstract static class Endpoint.Rest extends Endpoint
This is the base REST endpoint.There are two recommended ways to create your own endpoint. The first method allows to provide the data processing function and registers automatically the template in the factory and the instance in the registry:
Endpoint.Rest.Type endpoint = new Endpoint.Rest() { } // <-- note the '{ }' to create a new anonymous class .template() // <-- create the template and register it in the factory // add all your template documentation .summary("Says hello to the world") .create() // <-- create an instance of the entity and register it in the registry .<Rest.Type>cast() // set the rest endpoint logic .process(() -> Data.map().put("hello", "world")) // <-- the endpoint logic // set the generic endpoint settings .url("/hello") .method("GET");
If you need more control over the endpoint behavior such as private member variables or multiple methods, then you need to declare a custom entity end register it before calling the template method:
public static class Hello extends Endpoint.Rest.Type { private String who = "world"; private Data hello() { return Data.map().put("hello", who); } public Data process() { return hello(); } } Endpoint.Rest.Type endpoint = new Endpoint.Rest() { } // <-- note the '{ }' to create a new anonymous class // register the custom entity before calling the template .target(Hello.class) .creator(Hello::new) .template() // <-- create the template and register it in the factory // add all your template documentation .summary("Says hello to the world") .create() // <-- create an instance of the entity and register it in the registry // set the generic endpoint settings .url("/hello") .method("GET");
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Endpoint.Rest.Type
This is the base REST endpoint type.-
Nested classes/interfaces inherited from class aeonics.http.Endpoint
Endpoint.File, Endpoint.Rest, Endpoint.Template, Endpoint.Websocket
-
-
Constructor Summary
Constructors Constructor Description Rest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.function.Supplier<? extends Endpoint.Rest.Type>
defaultCreator()
Returns the default target entity creator.protected java.lang.Class<? extends Endpoint.Rest.Type>
defaultTarget()
Returns the default target entity type.Endpoint.Template
template()
Returns the template to build the target entity.
-
-
-
Method Detail
-
defaultTarget
protected java.lang.Class<? extends Endpoint.Rest.Type> defaultTarget()
Description copied from class:Item
Returns the default target entity type. This method should be implemented by subclasses to specify the target entity type.- Specified by:
defaultTarget
in classItem<Endpoint.Type>
- Returns:
- the default target entity type
-
defaultCreator
protected java.util.function.Supplier<? extends Endpoint.Rest.Type> defaultCreator()
Description copied from class:Item
Returns the default target entity creator. This method should be implemented by subclasses to specify the entity creator.- Specified by:
defaultCreator
in classItem<Endpoint.Type>
- Returns:
- the default target entity creator
-
template
public Endpoint.Template template()
Description copied from class:Item
Returns the template to build the target entity.This method should ultimately be used to provide the final entity template. Although, it may also provide a partial template that subclassed may complement.
-
-