#[derive(CandidType, Deserialize)]
pub struct HeaderField(pub String, pub String);
#[derive(CandidType, Deserialize)]
pub struct HttpRequest {
pub url: String,
pub method: String,
pub body: serde_bytes::ByteBuf,
pub headers: Vec<HeaderField>,
}
#[derive(CandidType, Deserialize)]
pub struct HttpResponse {
pub body: serde_bytes::ByteBuf,
pub headers: Vec<HeaderField>,
pub status_code: u16,
}
#[query]
fn http_request(req: HttpRequest) -> HttpResponse {
HttpResponse {
status_code: 200,
headers: vec![HeaderField("Content-Type".into(), "text/plain".into())],
body: serde_bytes::ByteBuf::from(b"No image found".to_vec()),
}
}
Candid:
type HeaderField = record { text; text; };
type HttpRequest = record {
method: text;
url: text;
headers: vec HeaderField;
body: blob;
};
type HttpResponse = record {
status_code: nat16;
headers: vec HeaderField;
body: blob;
};
service : () -> {
http_request: (request: HttpRequest) -> (HttpResponse) query;
}
When trying to access canister at https://canister_id.icp0.io/
I receive: Error 503 Response Verification Error
What am I doing wrong?