HttpEndpoint class

Used for creating HTTP endpoints. An endpoint is a URL, at which a given service can be accessed by a client.

Configuration parameters

Parameters to pass to the configure method for component configuration:

  • cors_headers - a comma-separated list of allowed CORS headers

  • cors_origins - a comma-separated list of allowed CORS origins

  • cors_headers - a comma-separated list of allowed CORS headers

  • cors_origins - a comma-separated list of allowed CORS origins

  • connection(s) - the connection resolver's connections:

    • 'connection.discovery_key' - the key to use for connection resolving in a discovery service;
    • 'connection.protocol' - the connection's protocol;
    • 'connection.host' - the target host;
    • 'connection.port' - the target port;
    • 'connection.uri' - the target URI.
  • credential - the HTTPS credentials:

    • 'credential.ssl_key_file' - the SSL private key in PEM
    • 'credential.ssl_crt_file' - the SSL certificate in PEM
    • 'credential.ssl_ca_file' - the certificate authorities (root cerfiticates) in PEM

References

A logger, counters, and a connection resolver can be referenced by passing the following references to the object's setReferences method:

  • logger: '\*:logger:\*:\*:1.0';
  • counters: '\*:counters:\*:\*:1.0';
  • discovery: '\*:discovery:\*:\*:1.0' (for the connection resolver).

Examples

public MyMethod(ConfigParams _config, IReferences _references) {
    var endpoint = HttpEndpoint();
    if (config != null)
        endpoint.configure(_config);
    if (references)
        endpoint.setReferences(references);
    ...

    _endpoint.open(correlationId)
    _opened = true;

    ...
}

Constructors

HttpEndpoint()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close(String? correlationId) Future
Closes this endpoint and the REST server (service) that was opened earlier.
configure(ConfigParams config) → void
Configures this HttpEndpoint using the given configuration parameters.
getCorrelationId(Request req) String?
Returns correlationId from request
getServer() HttpServer?
Gets an HTTP server instance. Returns an HTTP server instance of null if endpoint is closed.
isOpen() bool
Returns whether or not this endpoint is open with an actively listening REST server.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open(String? correlationId) Future
Opens a connection using the parameters resolved by the referenced connection resolver and creates a REST server (service) using the set options and parameters.
register(IRegisterable registration) → void
Registers a registerable object for dynamic endpoint discovery.
registerInterceptor(String? route, dynamic action(Request req)) → void
Registers a middleware action for the given route.
registerRoute(String method, String route, Schema? schema, FutureOr<Response> action(Request req)) → void
Registers an action in this objects REST server (service) by the given method and route.
registerRouteWithAuth(String method, String route, Schema schema, FutureOr<Response?> authorize(Request req, Future next())?, FutureOr<Response> action(Request req)) → void
Registers an action with authorization in this objects REST server (service) by the given method and route.
setReferences(IReferences references) → void
Sets references to this endpoint's logger, counters, and connection resolver.
toString() String
A string representation of this object.
inherited
unregister(IRegisterable registration) → void
Unregisters a registerable object, so that it is no longer used in dynamic endpoint discovery.

Operators

operator ==(Object other) bool
The equality operator.
inherited