Struct rapid_web::server::RapidServer
source · pub struct RapidServer {
pub port: Option<u16>,
pub base_route: Option<String>,
pub hostname: Option<String>,
}Fields§
§port: Option<u16>§base_route: Option<String>§hostname: Option<String>Implementations§
source§impl RapidServer
impl RapidServer
A custom actix-web server implementation for the Rapid Framework
Examples
use rapid_web::server::RapidServer;
let app = RapidServer::create(None, None, None, None);
app.listen(HttpServer::new(move || {
RapidServer::router(None).route("/", web::get().to(route))
})).await
pub fn create( port: Option<u16>, base_route: Option<String>, hostname: Option<String> ) -> Self
sourcepub fn router(
cors: Option<Cors>,
log_type: Option<RapidLogger>
) -> App<impl ServiceFactory<ServiceRequest, Response = ServiceResponse<impl MessageBody>, Config = (), InitError = (), Error = Error>>
pub fn router( cors: Option<Cors>, log_type: Option<RapidLogger> ) -> App<impl ServiceFactory<ServiceRequest, Response = ServiceResponse<impl MessageBody>, Config = (), InitError = (), Error = Error>>
A stock re-export of the actix-web “App::new()” router with a few extras Note: to experience the full capabilities of rapid-web, use the RapidServer::fs_router function
sourcepub fn fs_router(
cors: Option<Cors>,
log_type: Option<RapidLogger>,
routes: Scope
) -> App<impl ServiceFactory<ServiceRequest, Response = ServiceResponse<impl MessageBody>, Config = (), InitError = (), Error = Error>>
pub fn fs_router( cors: Option<Cors>, log_type: Option<RapidLogger>, routes: Scope ) -> App<impl ServiceFactory<ServiceRequest, Response = ServiceResponse<impl MessageBody>, Config = (), InitError = (), Error = Error>>
A file-system based router for the rapid-web
Build your api with a simple file based technique (ex: _middleware.rs, index.rs)
routes- A string slice that holds the path to the file system routes root directory (ex: “src/routes”) – this value can be anything as long as it is a valid (relative) directory path
sourcepub async fn listen<F, I, S, B>(
self,
server: HttpServer<F, I, S, B>
) -> Result<()>where
F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig> + 'static,
S::Error: Into<Error>,
S::InitError: Debug,
S::Response: Into<Response<B>>,
B: MessageBody + 'static,
pub async fn listen<F, I, S, B>( self, server: HttpServer<F, I, S, B> ) -> Result<()>where F: Fn() -> I + Send + Clone + 'static, I: IntoServiceFactory<S, Request>, S: ServiceFactory<Request, Config = AppConfig> + 'static, S::Error: Into<Error>, S::InitError: Debug, S::Response: Into<Response<B>>, B: MessageBody + 'static,
Takes in a pre-configured HttpServer and listens on the specified port(s)
Trait Implementations§
source§impl Clone for RapidServer
impl Clone for RapidServer
source§fn clone(&self) -> RapidServer
fn clone(&self) -> RapidServer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more