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.

32 lines
1.0 KiB

use hastic::services::user_service;
3 years ago
use warp::http::HeaderValue;
3 years ago
use warp::{Rejection, Reply};
use warp::filters::method::post;
use warp::{Filter, http::Response };
use serde::{ Serialize };
#[derive(Serialize)]
struct SigninResp {
token: user_service::AccessToken
}
3 years ago
pub fn get_route() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
return warp::path!("api" / "auth" / "signin")
.and(post())
.and(warp::body::json())
.map(|user: user_service::User| {
let token = "asdsad".to_string();
// user_service::
let j = warp::reply::json(&SigninResp{ token });
let mut rs = j.into_response();
let hs = rs.headers_mut();
hs.insert("Access-Control-Allow-Origin", HeaderValue::from_static("*"));
hs.insert("Access-Control-Allow-Methods", HeaderValue::from_static("POST, GET, OPTIONS, DELETE"));
hs.insert("Access-Control-Allow-Headers", HeaderValue::from_static("*"));
rs
// API::builder(j)
3 years ago
});
}