1#[cfg(feature = "backend")]
2use actix_web::{web, Route};
3
4#[derive(Copy, Clone, Eq, PartialEq, Debug)]
6pub enum Method {
7 Delete,
9
10 Get,
12
13 Patch,
15
16 Post,
18
19 Put,
21}
22
23#[cfg(feature = "backend")]
24impl Method {
25 #[must_use]
27 pub fn route(self) -> Route {
28 match self {
29 Self::Delete => web::delete(),
30 Self::Get => web::get(),
31 Self::Patch => web::patch(),
32 Self::Post => web::post(),
33 Self::Put => web::put(),
34 }
35 }
36}
37
38impl Method {
39 #[must_use]
41 pub const fn as_str(self) -> &'static str {
42 match self {
43 Self::Delete => "DELETE",
44 Self::Get => "GET",
45 Self::Patch => "PATCH",
46 Self::Post => "POST",
47 Self::Put => "PUT",
48 }
49 }
50}