You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Spin 2.0.1, the Rust template referenced the http crate, and we supported the Json<T> extractor as a body type parameter e,g, http::Request<Json<Person>>.
In Spin 2.1, the Rust template does not reference the http crate and users are directed instead to the spin_sdk::http::Request type. This type is not generic - the body is always presented as bytes - and we do not have seem to have samples of how to use the extractors with it. I guess you can do something like Jsion::<Person>::try_from_body(req.into_body()) but it's not as friendly as the extractor syntax!
If the extractors work with the SDK request type, it would be good to provide samples that show how; if they don't, we should provide that functionality.
The text was updated successfully, but these errors were encountered:
A json method feels very specific (although admittedly the "80% case" kind of specific, with String and maybe form-encoded being the other biggies). I had also wondered about a function called something like into_body_as() or extract, but the req.extract::<Json<Person>>() syntax is a bit spiky.
Another, although maybe hairy, possibility is a typed form of request e.g. spin_sdk::http::typed::Request<T>. It could be a testing and maintenance pain though, and of course a discoverability issue and extra cognitive load for users.
In Spin 2.0.1, the Rust template referenced the
http
crate, and we supported theJson<T>
extractor as a body type parameter e,g,http::Request<Json<Person>>
.In Spin 2.1, the Rust template does not reference the
http
crate and users are directed instead to thespin_sdk::http::Request
type. This type is not generic - the body is always presented as bytes - and we do not have seem to have samples of how to use the extractors with it. I guess you can do something likeJsion::<Person>::try_from_body(req.into_body())
but it's not as friendly as the extractor syntax!If the extractors work with the SDK request type, it would be good to provide samples that show how; if they don't, we should provide that functionality.
The text was updated successfully, but these errors were encountered: