1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! `rocket-post-as-delete` is a Fairing for [Rocket](https://rocket.rs) 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.
//!
//! # Example
//!
//! ```rust
//! use rocket::{launch, delete, routes};
//! use rocket_post_as_delete::PostAsDelete;
//!
//! #[launch]
//! fn rocket() -> _ {
//! rocket::build()
//! .attach(PostAsDelete)
//! .mount("/", routes![delete_foo_bar])
//! }
//!
//! #[delete("/foo/bar")]
//! async fn delete_foo_bar() -> String {
//! "Poof!".into()
//! }
//!
//! # use rocket::local::blocking::Client;
//! # use rocket::http::Status;
//! # let client = Client::tracked(rocket()).expect("valid rocket instance");
//! # let response = client.post("/foo/bar/delete").dispatch();
//! # assert_eq!(response.status(), Status::Ok);
//! # assert_eq!(response.into_string().unwrap(), "Poof!");
//! ```
//!
//! Now forms such as this (`POST` verb, and submit URL suffixed by `/delete`):
//! ```html
//! <form method="post" action="/foo/bar/delete">
//! <button>Delete me!</button>
//! </form>
//! ```
//!
//! Will run the `delete_foo_bar` route as expected.
use ;
;