pub struct Server {
pub hostname: String,
pub port: u16,
/* private fields */
}
Expand description
The “heart” of the module; the server struct
It does everything: process requests, pass them to handlers, reject them if they are malformed
Fields§
§hostname: String
The hostname the server is listening to for requests
port: u16
The port the server is listening for requests
Implementations§
Source§impl Server
impl Server
Sourcepub fn new<S, N>(hostname: S, port: N) -> Self
pub fn new<S, N>(hostname: S, port: N) -> Self
Initialize a Server
by passing a hostname and a port number
Sourcepub fn on<S, H>(&mut self, path: S, handler: H)
pub fn on<S, H>(&mut self, path: S, handler: H)
Append a function handler that will be called on any request in a specific path
Sourcepub fn on_get<S, H>(&mut self, path: S, handler: H)
pub fn on_get<S, H>(&mut self, path: S, handler: H)
Same as the on()
function, but processes only GET requests
Sourcepub fn on_head<S, H>(&mut self, path: S, handler: H)
pub fn on_head<S, H>(&mut self, path: S, handler: H)
Same as the on()
function, but processes only HEAD requests
Sourcepub fn on_post<S, H>(&mut self, path: S, handler: H)
pub fn on_post<S, H>(&mut self, path: S, handler: H)
Same as the on()
function, but processes only POST requests
Sourcepub fn on_put<S, H>(&mut self, path: S, handler: H)
pub fn on_put<S, H>(&mut self, path: S, handler: H)
Same as the on()
function, but processes only PUT requests
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl !Send for Server
impl !Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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