rocket-post-as-delete 0.1.1

A rocket fairing rewriting POST requests with delete suffix to their DELETE counterparts
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 5.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 799.62 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 28s Average build duration of successful builds.
  • all releases: 1m 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Misterio77/rocket-post-as-delete
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Misterio77

Rocket POST as DELETE Fairing

Crates.io Version

rocket-post-as-delete is a Fairing for Rocket rewriting requests such as POST foo/bar/delete into DELETE foo/bar.

This is useful when you have web forms (which, unless you use javascript, only support POST and GET) for deleting stuff, and want to write those routes with (the more correct) DELETE verb.

Installing

Add to your Cargo.toml:

rocket-post-as-delete = "0.1"

Usage

use rocket_post_as_delete::PostAsDelete;

#[rocket::main]
async fn main() {
   rocket::build()
       .attach(PostAsDelete)
       .mount("/", routes![delete_foo_bar])
       .launch()
       .await;
}

#[delete("/foo/bar")]
async fn delete_foo_bar() -> String {
    "Poof!"
}

Now forms such as this (POST verb, and submit URL suffixed by /delete):

<form method="post" action="/foo/bar/delete">
    <button>Delete me!</button>
</form>

Will run the delete_foo_bar route as expected.