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.
Add to your Cargo.toml
:
rocket-post-as-delete = "0.1"
```rust use rocketpostas_delete::PostAsDelete;
async fn main() { rocket::build() .attach(PostAsDelete) .mount("/", routes![deletefoobar]) .launch() .await; }
async fn deletefoobar() -> String { "Poof!" } ```
Now forms such as this (POST
verb, and submit URL suffixed by /delete
):
```html
```
Will run the delete_foo_bar
route as expected.