- java.lang.Object
-
- aeonics.entity.Entity
-
- aeonics.http.Endpoint.Type
-
- All Implemented Interfaces:
Exportable
,Snapshotable
- Direct Known Subclasses:
Endpoint.File.Type
,Endpoint.Rest.Type
,Endpoint.Websocket.Type
- Enclosing class:
- Endpoint
public abstract static class Endpoint.Type extends Entity
This is the base endpoint.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Type()
Empty constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
category()
Hardcoded category to theEndpoint
classData
export()
The default entity export implementation includes informational metadata fields as well as all declaredEntity.parameters()
and all declaredEntity.relationships()
.boolean
matches(java.lang.String url)
Returns true if the provided URL matches this endpointjava.lang.String
method()
Returns the HTTP method this endpoint accepts<T extends Endpoint.Type>
Tmethod(java.lang.String value)
Set the HTTP method this endpoint acceptsjava.lang.String
name()
Returns this entity name<T extends Entity>
Tname(java.lang.String value)
Sets this entity name.abstract Data
process(Message request)
Processes the request and generates a response.java.lang.String
url()
Returns the URL of this endpoint<T extends Endpoint.Type>
Turl(java.lang.String value)
Sets the URL of this endpoint-
Methods inherited from class aeonics.entity.Entity
addRelation, addRelation, addRelation, cast, clearRelation, config, defineRelation, equals, firstRelation, hashCode, hasRelation, id, internal, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, type, valueOf, valueOf
-
-
-
-
Method Detail
-
method
public java.lang.String method()
Returns the HTTP method this endpoint accepts- Returns:
- the HTTP method this endpoint accepts
-
method
public <T extends Endpoint.Type> T method(java.lang.String value)
Set the HTTP method this endpoint accepts- Type Parameters:
T
- this endpoint type- Parameters:
value
- the HTTP method this endpoint accepts- Returns:
- this
-
url
public java.lang.String url()
Returns the URL of this endpoint- Returns:
- the URL of this endpoint
-
url
public <T extends Endpoint.Type> T url(java.lang.String value)
Sets the URL of this endpoint- Type Parameters:
T
- this endpoint type- Parameters:
value
- the URL of this endpoint- Returns:
- this
-
matches
public boolean matches(java.lang.String url)
Returns true if the provided URL matches this endpoint- Parameters:
url
- the URL to compare- Returns:
- true if the provided URL matches this endpoint
-
process
public abstract Data process(Message request) throws java.lang.Exception
Processes the request and generates a response.The generated response can be any of the following:
- null: a 204 response is sent
- an exception: it is the same as if you throw it
- a scalar data type: it is sent as-is with an
'application/octet-stream'
mime type and a code 200 - a list or map data type: it is converted to its JSON representation and sent with an
'application/json'
mime type and a code 200 - a special response data map containing:
- isHttpResponse [required]: true [required]
- code: the http status code to send. Default 200.
- status: the http status text. If not specified, it will be derived from the response code.
- mime: the mime type to send. Default 'application/octet-stream'.
- body: the content to send (if a data map or list, then its JSON representation is used). Default to "".
- headers: any http response headers to send as a data map.
- Parameters:
request
- the original message data- Returns:
- the generated response
- Throws:
java.lang.Exception
- if anything happens, the exception will be wrapped in anHttpException
-
export
public Data export()
Description copied from class:Entity
The default entity export implementation includes informational metadata fields as well as all declaredEntity.parameters()
and all declaredEntity.relationships()
.If there are potentially private or confidential data returned by the default implementation, you should override it and modify the result before returning it.
Note that you may provide your own custom implementation although it may introduce inconsistencies with the frontent application in case of unexpected format or missing information. Therefore, it is always prefeable to call
super.export()
and manipulate the result instead.- Specified by:
export
in interfaceExportable
- Overrides:
export
in classEntity
- Returns:
- a public data representation of this class instance
-
name
public java.lang.String name()
Description copied from class:Entity
Returns this entity name
-
name
public <T extends Entity> T name(java.lang.String value)
Description copied from class:Entity
Sets this entity name.
-
category
public final java.lang.String category()
Hardcoded category to theEndpoint
class- Overrides:
category
in classEntity
- Returns:
- the entity category
- See Also:
Registry.of(String)
-
-