Skip to content

cognitedata/rocket-enumform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rocket extension to permit enums in application/x-www-form-urlencoded forms

This crate is a workaround for https://github.com/SergioBenitez/Rocket/issues/1937.

It is derived from the included serde_json implementation in rocket.

#[derive(Debug, Deserialize)]
#[serde(tag = "type")]
enum Body {
    #[serde(rename = "variant_one")]
    VariantOne(VariantOne),
    #[serde(rename = "variant_two")]
    VariantTwo(VariantTwo),
}

#[derive(Debug, Deserialize)]
struct VariantOne {
    content_one: String
}

#[derive(Debug, Deserialize)]
struct VariantTwo {
    content_two: String
}

#[post("/form", format = "form", data = "<data>")]
fn body(data: UrlEncoded<Body>) -> String { /*...*/ }

status

Works but not unit tested, nor have local testing affordances for users been added yet.

Supports rust stable and nightly, matching Rocket.

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Contributing

PR's on Github as normal please. Cargo test and rustfmt code before submitting.

About

A serde_urlencoded form implementation

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages