Skip to content

Commit 7a2ae63

Browse files
authored
Merge branch 'main' into jessie-patch-3
2 parents 774262d + d0bc921 commit 7a2ae63

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Unreleased
2+
13
## 3.0.3 (2025-02-04)
24

35
### Fix

examples/http-certification/json-api/src/backend/src/types.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ic_http_certification::{HttpRequest, HttpResponse};
1+
use ic_http_certification::{HttpRequest, HttpResponse, StatusCode};
22
use matchit::Params;
33
use serde::{Deserialize, Serialize};
44

@@ -18,20 +18,26 @@ pub enum ApiResponse<'a, T = ()> {
1818
}
1919

2020
impl<'a, T: Serialize> ApiResponse<'a, T> {
21-
pub fn ok(data: &'a T) -> ApiResponse<T> {
21+
pub fn ok(data: &'a T) -> ApiResponse<'a, T> {
2222
Self::Ok { data }
2323
}
2424

2525
pub fn not_found() -> Self {
26-
Self::err(404, "Not found".to_string())
26+
Self::err(StatusCode::NOT_FOUND, "Not found".to_string())
2727
}
2828

2929
pub fn not_allowed() -> Self {
30-
Self::err(405, "Method not allowed".to_string())
30+
Self::err(
31+
StatusCode::METHOD_NOT_ALLOWED,
32+
"Method not allowed".to_string(),
33+
)
3134
}
3235

33-
fn err(code: u16, message: String) -> Self {
34-
Self::Err { code, message }
36+
fn err(code: StatusCode, message: String) -> Self {
37+
Self::Err {
38+
code: code.as_u16(),
39+
message,
40+
}
3541
}
3642

3743
pub fn encode(&self) -> Vec<u8> {

0 commit comments

Comments
 (0)