Hastic standalone https://hastic.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
843 B

3 years ago
use warp::{Rejection, Reply, body};
3 years ago
use warp::{Filter, http::Response };
use warp::filters::method::post;
3 years ago
mod auth;
3 years ago
3 years ago
pub struct API {
3 years ago
}
impl API {
fn new() -> API {
API{}
}
fn builder<T>(s: T) -> Result<Response<T>, warp::http::Error> {
3 years ago
return Response::builder()
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE")
.header("Access-Control-Allow-Headers", "*")
.body(s)
3 years ago
}
pub async fn serve() {
let lg = warp::any().map(move || API::builder("not found") );
3 years ago
let login = auth::get_route();
3 years ago
println!("Start server on 8000 port");
3 years ago
warp::serve(login.
or(lg)
3 years ago
)
3 years ago
.run(([127, 0, 0, 1], 8000))
.await;
}
}