Skip to main content

Module server

Module server 

Source
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:

  • LxJson to deserialize from HTTP body JSON
  • LxQuery to deserialize from query strings

§IntoResponse types / impls for building Lexe API-conformant responses:

Modules§

extract
middleware

Structs§

LayerConfig
A configuration object for Axum / Tower middleware.
LxBytes
A version of Bytes which conforms to Lexe’s (binary) API.
LxJson
A version of axum::Json which conforms to Lexe’s (JSON) API. It can be used as either an extractor or a response.
LxRejection
Our own axum::extract::rejection type with an IntoResponse impl 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_fut but takes a TcpListener instead of SocketAddr.
build_server_url
Construct a server URL given the TcpListener::local_addr from by a server’s TcpListener, 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_fut but 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_task but takes TcpListener instead of SocketAddr.