Module aeonics.http
Package aeonics.http

Class Endpoint.Type

    • Constructor Detail

      • Type

        protected Type()
        Empty constructor
    • 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 an HttpException
      • export

        public Data export()
        Description copied from class: Entity
        The default entity export implementation includes informational metadata fields as well as all declared Entity.parameters() and all declared Entity.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 interface Exportable
        Overrides:
        export in class Entity
        Returns:
        a public data representation of this class instance
      • name

        public java.lang.String name()
        Description copied from class: Entity
        Returns this entity name
        Overrides:
        name in 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.
        Overrides:
        name in class Entity
        Type Parameters:
        T - this
        Parameters:
        value - this entity name
        Returns:
        this