use crate::{internals::*, pkg::error::Error}; use http::header::HeaderMap; use std::{collections::HashMap, net::SocketAddr, sync::Arc}; pub type HttpResponse = Result; pub trait Responder: Send { fn respond(self: Box) -> RespFuture; } #[derive(Clone, Debug, PartialEq)] pub enum Method { ALL, GET, POST, PUT, DELETE, } #[derive(Copy, Clone, Debug, PartialEq)] pub enum StatusCode { Ok = 200, Created = 201, NoContent = 204, MovedPermanently = 301, Found = 302, SeeOther = 303, NotModified = 304, TemporaryRedirect = 307, BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, InternalServerError = 500, } #[derive(Clone, Debug)] pub struct Request { pub method: Method, pub path: String, pub headers: HeaderMap, pub body: Vec, pub params: HashMap, pub query: HashMap, } #[derive(Clone, Debug)] pub struct Response { pub path: String, pub status: StatusCode, pub headers: HeaderMap, pub body: Vec, } #[derive(Clone)] pub struct Router { pub routes: Vec<(Method, String, Arc HttpFuture + Send + Sync>)>, } pub struct Server { pub(crate) addr: SocketAddr, }