Expand description
Webserver utilities. This module provides various API server utilities.
§Serving
Methods to serve a Router with a fallback handler (for unmatched paths),
tracing / request instrumentation, backpressure, load shedding, concurrency
limits, server-side timeouts, TLS, and graceful shutdown:
§Extractors to get data from requests:
§IntoResponse types / impls for building Lexe API-conformant responses:
LxJsontype for returning success responses as JSON- All
ApiErrors andCommonApiErrorimplIntoResponse LxRejectionfor notifying clients of bad JSON, query strings, etc.
Modules§
Structs§
- Layer
Config - A configuration object for Axum / Tower middleware.
- LxBytes
- A version of
Byteswhich conforms to Lexe’s (binary) API. - LxJson
- A version of
axum::Jsonwhich conforms to Lexe’s (JSON) API. It can be used as either an extractor or a response. - LxRejection
- Our own
axum::extract::rejectiontype with anIntoResponseimpl which conforms to Lexe’s API. Contains the source rejection’s error text.
Constants§
- SERVER_
HANDLER_ TIMEOUT - The default maximum time a server can spend handling a request.
- SERVER_
SHUTDOWN_ TIMEOUT - The maximum time we’ll wait for a server to complete shutdown.
Functions§
- build_
server_ fut - Constructs an API server future which can be spawned into a task. Additionally returns the server url.
- build_
server_ fut_ with_ listener build_server_futbut takes aTcpListenerinstead ofSocketAddr.- build_
server_ url - Construct a server URL given the
TcpListener::local_addrfrom by a server’sTcpListener, and its DNS name. - default_
fallback - Lexe’s default fallback
Handler. Returns a “bad endpoint” rejection along with the requested method and path. - spawn_
server_ task build_server_futbut additionally spawns the server future into an instrumented server task and logs the full URL used to access the server. Returns the server task and server url.- spawn_
server_ task_ with_ listener spawn_server_taskbut takesTcpListenerinstead ofSocketAddr.