Skip to content

Commit

Permalink
Fix POST submission endpoint
Browse files Browse the repository at this point in the history
Ensures the HTTP statuc code for a POST request is 201.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho committed Oct 31, 2024
1 parent 40a6604 commit db4ed05
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lambdas/src/bin/cities/post-cities-submissions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use dotenv::dotenv;
use effortless::{api::parse_request_body, error::APIErrors};
use effortless::{api::parse_request_body, error::APIErrors, response::make_json_created_response};
use entity::wrappers::submission::SubmissionPost;
use lambda_http::{run, service_fn, Body, Error, IntoResponse, Request, Response};
use lambda_http::{run, service_fn, Body, Error, Request, Response};
use lambdas::core::resource::cities::adaptor::post_cities_submission_adaptor;
use serde_json::json;
use tracing::info;

async fn function_handler(event: Request) -> Result<Response<Body>, Error> {
Expand All @@ -16,7 +17,8 @@ async fn function_handler(event: Request) -> Result<Response<Body>, Error> {
// let country = wrapper.country.clone();

match post_cities_submission_adaptor(wrapper).await {
Ok(v) => Ok(v.into_response().await),
Ok(v) => Ok(make_json_created_response(json!(v).to_string())
.expect("unable to build http::Response")),
Err(e) => Ok(APIErrors::from(e).into()),
}
}
Expand Down

0 comments on commit db4ed05

Please sign in to comment.