Browse Source

Remove api prefix from routes #1

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
245f60b658
  1. 9
      server/src/api.rs
  2. 2
      server/src/api/auth.rs
  3. 2
      server/src/api/metric.rs

9
server/src/api.rs

@ -82,10 +82,11 @@ impl API<'_> {
println!("Start server on {} port", self.config.port);
// TODO: move it to "server"
let routes = login
.or(metrics)
//.or(segments)
.or(options)
let routes =
warp::path("api")
.and(
login.or(metrics).or(options))
.or(public)
.or(not_found);
warp::serve(routes).run(([127, 0, 0, 1], self.config.port)).await;

2
server/src/api/auth.rs

@ -21,7 +21,7 @@ struct SigninResp {
pub fn get_route(
user_service: Arc<RwLock<user_service::UserService>>,
) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
return warp::path!("api" / "auth" / "signin")
return warp::path!("auth" / "signin")
.and(post())
.and(warp::body::json())
.map(move |user: user_service::User| {

2
server/src/api/metric.rs

@ -66,7 +66,7 @@ async fn query(
pub fn get_route(
metric_service: Arc<RwLock<metric_service::MetricService>>,
) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
return warp::path!("api" / "metric")
return warp::path!("metric")
.and(get())
.and(warp::query::<HashMap<String, String>>())
.and(warp::any().map(move || metric_service.clone()))

Loading…
Cancel
Save