I have a project written in Rocket with the endpoint /foo
that returns data in application/json
. I'm using rocket, rocket_codegen, serde, and serde_json.
#[get("/foo")]
fn foo() -> Json {
Json(json!({
"foo": 1
}))
}
This works nicely, but I need to respond with application/hal+json
so I guess I need to write my own response, and I have failed. How do I return my JSON with the Content-Type application/hal+json
?
I got some help over at the projects chat and the solution was: