CustomDirectives

com.netflix.atlas.pekko.CustomDirectives

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def accessLog(headers: List[HttpHeader]): Directive0

Generate an access log using spectator HttpLogEntry utility.

Generate an access log using spectator HttpLogEntry utility.

Value parameters

headers

Additional headers to apply to the response before passing to the logger. This is intended for providing additional context such as the server group and zone of the particular server instance with common IPC.

Attributes

def closeConnection(probability: Double): Directive0

Add connection close header to some responses. This can be useful when using network load balancers to allow some connection reuse, but force connections to close frequently enough to ensure that traffic balances across instances.

Add connection close header to some responses. This can be useful when using network load balancers to allow some connection reuse, but force connections to close frequently enough to ensure that traffic balances across instances.

Value parameters

probability

A value of 0.0 means it will never be added, 1.0 means it will always be added.

Attributes

def cors(hosts: List[String])(inner: Route): Route

Wraps a route with support for CORS. This will handle the preflight checks as well as adding the appropriate headers to the response of the inner route.

Wraps a route with support for CORS. This will handle the preflight checks as well as adding the appropriate headers to the response of the inner route.

Attributes

def corsPreflight(hosts: List[String]): Route

Route for CORS handling pre-flight checks.

Route for CORS handling pre-flight checks.

Attributes

def customJson[T : JavaTypeable](decoder: JsonParser => T): MediaType => ByteString => T

Used with parseEntity to decode the request entity to an object of type T using a custom decoder function. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Used with parseEntity to decode the request entity to an object of type T using a custom decoder function. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Attributes

def endpointPath(pm: PathMatcher[Unit]): Directive0

Alternative to the built-in path directive that will set the Netflix-Endpoint header based on the currently matched path. To avoid matching paths with arbitrary values that should not be a part of the header, the path matcher is restricted so that values cannot be extracted. Use endpointPathPrefix with a nested path directive for those use-cases.

Alternative to the built-in path directive that will set the Netflix-Endpoint header based on the currently matched path. To avoid matching paths with arbitrary values that should not be a part of the header, the path matcher is restricted so that values cannot be extracted. Use endpointPathPrefix with a nested path directive for those use-cases.

Attributes

def endpointPath[L](prefix: PathMatcher[Unit], remaining: PathMatcher[L]): Directive[L]

This is a convenience directive for the common pattern of have a fixed path with an extracted portion such as an identifier at the end. It will set the endpoint header based on the prefix matcher. Example:

This is a convenience directive for the common pattern of have a fixed path with an extracted portion such as an identifier at the end. It will set the endpoint header based on the prefix matcher. Example:

endpointPathPrefix("api" / "v1" / "instances") {
 path(Remaining) { id =>
   ...
 }
}

Can instead be written as:

endpointPath("api" / "v1" / "instances", Remaining) { id =>
 ...
}

Attributes

def endpointPathPrefix(pm: PathMatcher[Unit]): Directive0

Alternative to the built-in pathPrefix directive that will set the Netflix-Endpoint header based on the currently matched path. To avoid matching paths with arbitrary values that should not be a part of the header, the path matcher is restricted so that values cannot be extracted.

Alternative to the built-in pathPrefix directive that will set the Netflix-Endpoint header based on the currently matched path. To avoid matching paths with arbitrary values that should not be a part of the header, the path matcher is restricted so that values cannot be extracted.

Attributes

def json[T : JavaTypeable]: MediaType => ByteString => T

Used with parseEntity to decode the request entity to an object of type T using the default ObjectMapper from atlas-json. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Used with parseEntity to decode the request entity to an object of type T using the default ObjectMapper from atlas-json. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Note: This is kept as a separate function passed into the parseEntity directive because adding the manifest to T causes problems when used directly on the directive. It also makes it possible to reuse parseEntity with a custom function.

Attributes

def jsonUnmarshaller[T : JavaTypeable]: FromRequestUnmarshaller[T]

Used with entity to decode the request entity to an object of type T using the default ObjectMapper from atlas-json. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Used with entity to decode the request entity to an object of type T using the default ObjectMapper from atlas-json. If the content type is application/x-jackson-smile, then a smile parser will be used. Otherwise it will be treated as application/json regardless of the content type.

Attributes

def jsonpFilter: Directive0

Returns a JSONP response. This directive will always try to return a 200 response so that the javascript code in the browser can better deal with errors. The actual response status code and headers will be included as part of the JSON object returned.

Returns a JSONP response. This directive will always try to return a 200 response so that the javascript code in the browser can better deal with errors. The actual response status code and headers will be included as part of the JSON object returned.

Attributes

def parseEntity[T](f: MediaType => ByteString => T): Directive1[T]

Parses the request entity into an object of type T. The parsing is done by passing in the complete request data to the function f.

Parses the request entity into an object of type T. The parsing is done by passing in the complete request data to the function f.

Attributes

def respondWithCorsHeaders(hosts: List[String]): Directive0

Filter to provide basic CORS support. By default it assumes that actual security is provided elsewhere. The goal for this filter is to allow javascript UIs or other tools to access the APIs and work with minimal fuss.

Filter to provide basic CORS support. By default it assumes that actual security is provided elsewhere. The goal for this filter is to allow javascript UIs or other tools to access the APIs and work with minimal fuss.

The hosts param specifies a whitelist for allowing cross-origin requests. Default is no requests will get CORS headers.

Attributes

def respondWithEndpointHeader: Directive0

Adds the Netflix-Endpoint header to the response if it is not already present. This directive is typically not used directly, it is preferred to use one of the endpointPath* directives instead.

Adds the Netflix-Endpoint header to the response if it is not already present. This directive is typically not used directly, it is preferred to use one of the endpointPath* directives instead.

Attributes