pub struct RapidServer {
pub port: Option<u16>,
pub hostname: Option<String>,
}Fields§
§port: Option<u16>§hostname: Option<String>Implementations§
Source§impl RapidServer
A custom actix-web server implementation for the Rapid Framework
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>, 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 This router does not support type-safe file based routing Note: to experience the full capabilities of rapid-web, we recommend using 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 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 pathcors- An optional cors value that can be used to configure the cors middlewarelog_type- An optional logger type that can be used to configure the logger middleware used for every request/response
Docs coming soon…
Sourcepub async fn listen<F, I, S, B>(
self,
server: HttpServer<F, I, S, B>,
) -> Result<()>
pub async fn listen<F, I, S, B>( self, server: HttpServer<F, I, S, B>, ) -> Result<()>
Takes in a pre-configured HttpServer and listens on the specified port(s)
§Notes
This function will try to initalize a logger in case one has not already been initalized. If you would like to use your own logger, make sure it has been initalized before this function is called
Trait Implementations§
Source§impl Clone for RapidServer
impl Clone for RapidServer
Source§fn clone(&self) -> RapidServer
fn clone(&self) -> RapidServer
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for RapidServer
impl RefUnwindSafe for RapidServer
impl Send for RapidServer
impl Sync for RapidServer
impl Unpin for RapidServer
impl UnwindSafe for RapidServer
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
Mutably borrows from an owned value. Read more