Alexey Velikiy
3 years ago
2 changed files with 25 additions and 11 deletions
@ -1,32 +1,27 @@
|
||||
use hastic::services::user_service; |
||||
|
||||
use warp::http::HeaderValue; |
||||
use warp::hyper::Body; |
||||
use warp::{Rejection, Reply}; |
||||
use warp::filters::method::post; |
||||
use warp::{Filter, http::Response }; |
||||
|
||||
use serde::{ Serialize }; |
||||
|
||||
use crate::api; |
||||
|
||||
#[derive(Serialize)] |
||||
struct SigninResp { |
||||
token: user_service::AccessToken |
||||
} |
||||
|
||||
|
||||
|
||||
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)
|
||||
api::API::json(&SigninResp { token: "asdad".to_string() }) |
||||
}); |
||||
} |
Loading…
Reference in new issue