diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-03-19 20:27:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 20:27:53 +0100 |
commit | 4249c2e09579d6454e7572111e44c284190a2c8f (patch) | |
tree | fc47bb02aa430accce176903af5e36b81179c87a /src/repository | |
parent | 9a791db0c1a8bd08cf51950ed28066adcef84bca (diff) | |
parent | 8225cba5ce69a073b54e2eeba7c9d466efa107e3 (diff) |
Merge pull request #20 from gico-net/feat/cors
Enable CORS
Diffstat (limited to 'src/repository')
-rw-r--r-- | src/repository/routes.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/repository/routes.rs b/src/repository/routes.rs index 32443b1..d189584 100644 --- a/src/repository/routes.rs +++ b/src/repository/routes.rs @@ -27,15 +27,15 @@ async fn index(state: web::Data<AppState>) -> impl Responder { /// It is a String, casted in an Uuid format. async fn get_repo( state: web::Data<AppState>, - id: web::Path<(String,)>, + id: web::Path<String>, ) -> impl Responder { // I have to match the &id.0 because if it's not a valid Uuid, the server // must response "Repository not found". // If I pass a not valid Uuid to Repository::find() it raises an error. - let uuid: Uuid = uuid_from_string(&id.0); + let uuid: Uuid = uuid_from_string(&id); let result = Repository::find(state.pool.clone(), &uuid).await; - info!(state.log, "GET /repo/{}/", id.0); + info!(state.log, "GET /repo/{}/", id); // `map_err` is also used when repo is not found result @@ -48,9 +48,9 @@ async fn get_repo( async fn delete_repo( req: HttpRequest, state: web::Data<AppState>, - id: web::Path<(String,)>, + id: web::Path<String>, ) -> impl Responder { - let uuid: Uuid = uuid_from_string(&id.0); + let uuid: Uuid = uuid_from_string(&id); match req.headers().get(header::AUTHORIZATION) { Some(x) if x.to_str().unwrap() @@ -102,12 +102,12 @@ pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("/repo") .service( - web::resource("{_:/?}") + web::resource("/") .route(web::get().to(index)) .route(web::post().to(create_repo)), ) .service( - web::resource("/{id}{_:/?}") + web::resource("/{id}/") .route(web::get().to(get_repo)) .route(web::delete().to(delete_repo)), ), |