Struct spot::Spot[][src]

pub struct Spot { /* fields omitted */ }

Implementations

impl Spot[src]

pub fn new(amount_of_threads: usize) -> Spot[src]

Returns a Spot HTTP server instance with worker threads equal to the specified amount.

#Panics

panics if amount of threads is 0

pub fn middle(
    &mut self,
    path: &str,
    function: fn(_: Request, _: Response) -> (Request, Response, bool)
)
[src]

Add middleware for specified resources.

The middleware function takes inn a function that returns a modified response and request, aswell as a boolean is true if the request should be forwarded or false if you wish the server to write the current response.

pub fn route(
    &mut self,
    path: &str,
    function: fn(_: Request, _: Response) -> Response
)
[src]

Add a http resource route which takes in the request and a premade respons, then returns a modifed response that is written to the client

pub fn route_file(&mut self, path: &str)[src]

Add a file to routes, it’s route is equal to the path where the file lies

pub fn public(&mut self, dir_name: &str)[src]

Make all the files in the specified directory publicly avalible

pub fn bind(&mut self, ip: &str) -> String[src]

Bind the server to the specified IP address and listen for inncomming http requests

Auto Trait Implementations

impl RefUnwindSafe for Spot

impl Send for Spot

impl Sync for Spot

impl Unpin for Spot

impl UnwindSafe for Spot

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.