Struct actix_web::web::ServiceConfig  
source · [−]pub struct ServiceConfig { /* private fields */ }Expand description
Enables parts of app configuration to be declared separately from the app itself. Helpful for modularizing large applications.
Merge a ServiceConfig into an app using App::configure. Scope and
resources services have similar methods.
use actix_web::{web, App, HttpResponse};
// this function could be located in different module
fn config(cfg: &mut web::ServiceConfig) {
    cfg.service(web::resource("/test")
        .route(web::get().to(|| HttpResponse::Ok()))
        .route(web::head().to(|| HttpResponse::MethodNotAllowed()))
    );
}
// merge `/test` routes from config function to App
App::new().configure(config);Implementations
sourceimpl ServiceConfig
 
impl ServiceConfig
sourcepub fn data<U: 'static>(&mut self, data: U) -> &mut Self
 👎 Deprecated since 4.0.0: Use .app_data(Data::new(val)) instead.
pub fn data<U: 'static>(&mut self, data: U) -> &mut Self
Use .app_data(Data::new(val)) instead.
Add shared app data item.
Counterpart to App::data().
sourcepub fn app_data<U: 'static>(&mut self, ext: U) -> &mut Self
 
pub fn app_data<U: 'static>(&mut self, ext: U) -> &mut Self
Add arbitrary app data item.
Counterpart to App::app_data().
sourcepub fn route(&mut self, path: &str, route: Route) -> &mut Self
 
pub fn route(&mut self, path: &str, route: Route) -> &mut Self
Configure route for a specific path.
Counterpart to App::route().
sourcepub fn service<F>(&mut self, factory: F) -> &mut Self where
    F: HttpServiceFactory + 'static, 
 
pub fn service<F>(&mut self, factory: F) -> &mut Self where
    F: HttpServiceFactory + 'static, 
Register HTTP service factory.
Counterpart to App::service().
sourcepub fn external_resource<N, U>(&mut self, name: N, url: U) -> &mut Self where
    N: AsRef<str>,
    U: AsRef<str>, 
 
pub fn external_resource<N, U>(&mut self, name: N, url: U) -> &mut Self where
    N: AsRef<str>,
    U: AsRef<str>, 
Register an external resource.
External resources are useful for URL generation purposes only and are never considered for
matching at request time. Calls to HttpRequest::url_for()
will work as expected.
Counterpart to App::external_resource().
Auto Trait Implementations
impl !RefUnwindSafe for ServiceConfig
impl !Send for ServiceConfig
impl !Sync for ServiceConfig
impl Unpin for ServiceConfig
impl !UnwindSafe for ServiceConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
 
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
 
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
 
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
 
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
