Struct mini_server::HTTPServer
source · pub struct HTTPServer {
pub addr: &'static str,
pub port: u32,
pub paths: Vec<Path>,
/* private fields */
}
Expand description
HTTPServer
Example
use mini_server::*;
let server = MiniServer::init("localhost", 4221, ServerKind::HTTP);
if let MatchingServer::HTTP(mut app) = server {
app.get("/", |_| {
let mut response = HTTPResponse::default();
response.set_body("Hello World!".into());
response
});
// app.run();
}
Fields§
§addr: &'static str
§port: u32
§paths: Vec<Path>
Implementations§
source§impl HTTPServer
impl HTTPServer
pub fn new(addr: &'static str, port: u32) -> Self
pub fn connect(&mut self, path: &'static str, handler: RequestHandler)
pub fn delete(&mut self, path: &'static str, handler: RequestHandler)
pub fn get(&mut self, path: &'static str, handler: RequestHandler)
pub fn head(&mut self, path: &'static str, handler: RequestHandler)
pub fn options(&mut self, path: &'static str, handler: RequestHandler)
pub fn patch(&mut self, path: &'static str, handler: RequestHandler)
pub fn post(&mut self, path: &'static str, handler: RequestHandler)
pub fn put(&mut self, path: &'static str, handler: RequestHandler)
pub fn trace(&mut self, path: &'static str, handler: RequestHandler)
pub fn on_any(&mut self, handler: EventHandler)
Trait Implementations§
source§impl Clone for HTTPServer
impl Clone for HTTPServer
source§fn clone(&self) -> HTTPServer
fn clone(&self) -> HTTPServer
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 moresource§impl Server<&mut TcpStream, HTTPRequest> for HTTPServer
impl Server<&mut TcpStream, HTTPRequest> for HTTPServer
fn set_buffer_to(&mut self, size: usize)
fn on_ready(&mut self, handler: SoftEventHandler)
fn on_shutdown(&mut self, handler: SoftEventHandler)
fn handle_request(&mut self, stream: &mut TcpStream, req: HTTPRequest)
fn run(&mut self)
Auto Trait Implementations§
impl RefUnwindSafe for HTTPServer
impl Send for HTTPServer
impl Sync for HTTPServer
impl Unpin for HTTPServer
impl UnwindSafe for HTTPServer
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