diff options
Diffstat (limited to 'src/channel/routes/post.rs')
| -rw-r--r-- | src/channel/routes/post.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/channel/routes/post.rs b/src/channel/routes/post.rs index d694f8b..a05c312 100644 --- a/src/channel/routes/post.rs +++ b/src/channel/routes/post.rs @@ -17,14 +17,14 @@ pub async fn handler( _: Login, // requires auth, but doesn't actually care who you are RequestedAt(created_at): RequestedAt, Json(request): Json<Request>, -) -> Result<Json<Channel>, Error> { +) -> Result<Response, Error> { let channel = app .channels() .create(&request.name, &created_at) .await .map_err(Error)?; - Ok(Json(channel)) + Ok(Response(channel)) } #[derive(serde::Deserialize)] @@ -33,6 +33,16 @@ pub struct Request { } #[derive(Debug)] +pub struct Response(pub Channel); + +impl IntoResponse for Response { + fn into_response(self) -> response::Response { + let Self(channel) = self; + (StatusCode::ACCEPTED, Json(channel)).into_response() + } +} + +#[derive(Debug)] pub struct Error(pub app::CreateError); impl IntoResponse for Error { |
