pub struct RestServer { /* private fields */ }Expand description
Assembles and runs an Actix server with rust-zero’s standard production middleware.
Implementations§
Source§impl RestServer
impl RestServer
pub fn new(config: RestServerConfig) -> Result<Self, RestServerConfigError>
pub fn with_metrics( config: RestServerConfig, metrics: Arc<Metrics>, ) -> Result<Self, RestServerConfigError>
Sourcepub fn with_static_assets(self, static_assets: StaticAssets) -> Self
pub fn with_static_assets(self, static_assets: StaticAssets) -> Self
Installs an opt-in static-directory and/or embedded-asset fallback.
Sourcepub fn with_route_middleware<M>(
self,
name: impl Into<String>,
middleware: M,
) -> Result<Self, RestServerConfigError>where
M: RouteMiddleware,
pub fn with_route_middleware<M>(
self,
name: impl Into<String>,
middleware: M,
) -> Result<Self, RestServerConfigError>where
M: RouteMiddleware,
Registers application middleware referenced by declarative route groups.
Sourcepub fn with_response_policy(self, response_policy: ResponsePolicy) -> Self
pub fn with_response_policy(self, response_policy: ResponsePolicy) -> Self
Installs the response policy as Actix application data for all registered handlers.
Sourcepub fn with_content_encryption(
self,
content_encryption: ContentEncryption,
) -> Self
pub fn with_content_encryption( self, content_encryption: ContentEncryption, ) -> Self
Enables authenticated request decryption and buffered response encryption.
Install this only for APIs whose clients implement the versioned content-encryption wire format. Streaming routes such as SSE must remain on a server without this middleware.
pub fn config(&self) -> &RestServerConfig
pub fn metrics(&self) -> Arc<Metrics> ⓘ
pub fn response_policy(&self) -> &ResponsePolicy
Sourcepub async fn serverless_handler<F>(
&self,
configure: F,
) -> Result<ServerlessHandler, RestServerConfigError>where
F: FnOnce(&mut ServiceConfig) + 'static,
pub async fn serverless_handler<F>(
&self,
configure: F,
) -> Result<ServerlessHandler, RestServerConfigError>where
F: FnOnce(&mut ServiceConfig) + 'static,
Builds a reusable socket-free handler with the same routes, policies, middleware, and
static fallback as RestServer::run.
Sourcepub fn run<F>(&self, configure: F) -> Result<Server>
pub fn run<F>(&self, configure: F) -> Result<Server>
Binds the configured listener and installs the standard stack around application routes.
The configure callback is cloned per Actix worker and can register ordinary routes, resources, and scoped route groups.
Sourcepub fn run_on<F>(&self, listener: TcpListener, configure: F) -> Result<Server>
pub fn run_on<F>(&self, listener: TcpListener, configure: F) -> Result<Server>
Runs the configured stack on an existing listener.
Supplying the listener is useful for socket activation and lets tests reserve an ephemeral port without a bind race.
Sourcepub async fn serve_until<C, F>(&self, configure: C, shutdown: F) -> Result<()>
pub async fn serve_until<C, F>(&self, configure: C, shutdown: F) -> Result<()>
Serves until the supplied shutdown signal resolves, then gracefully drains requests.
Sourcepub async fn serve_on_until<C, F>(
&self,
listener: TcpListener,
configure: C,
shutdown: F,
) -> Result<()>
pub async fn serve_on_until<C, F>( &self, listener: TcpListener, configure: C, shutdown: F, ) -> Result<()>
Listener-based variant of RestServer::serve_until.
Trait Implementations§
Source§impl Clone for RestServer
impl Clone for RestServer
Source§fn clone(&self) -> RestServer
fn clone(&self) -> RestServer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RestServer
impl !UnwindSafe for RestServer
impl Freeze for RestServer
impl Send for RestServer
impl Sync for RestServer
impl Unpin for RestServer
impl UnsafeUnpin for RestServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request