Skip to content

Using the Json extractor with the 2.1 Rust template #23

@itowlson

Description

@itowlson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions