|
|
@@ -2,6 +2,7 @@ package com.ruoyi.common.enums;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.HashMap;
|
|
4
|
4
|
import java.util.Map;
|
|
|
5
|
+
|
|
5
|
6
|
import org.springframework.lang.Nullable;
|
|
6
|
7
|
|
|
7
|
8
|
/**
|
|
|
@@ -9,28 +10,23 @@ import org.springframework.lang.Nullable;
|
|
9
|
10
|
*
|
|
10
|
11
|
* @author ruoyi
|
|
11
|
12
|
*/
|
|
12
|
|
-public enum HttpMethod
|
|
13
|
|
-{
|
|
|
13
|
+public enum HttpMethod {
|
|
14
|
14
|
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
|
15
|
15
|
|
|
16
|
16
|
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
|
17
|
17
|
|
|
18
|
|
- static
|
|
19
|
|
- {
|
|
20
|
|
- for (HttpMethod httpMethod : values())
|
|
21
|
|
- {
|
|
|
18
|
+ static {
|
|
|
19
|
+ for (HttpMethod httpMethod : values()) {
|
|
22
|
20
|
mappings.put(httpMethod.name(), httpMethod);
|
|
23
|
21
|
}
|
|
24
|
22
|
}
|
|
25
|
23
|
|
|
26
|
24
|
@Nullable
|
|
27
|
|
- public static HttpMethod resolve(@Nullable String method)
|
|
28
|
|
- {
|
|
|
25
|
+ public static HttpMethod resolve(@Nullable String method) {
|
|
29
|
26
|
return (method != null ? mappings.get(method) : null);
|
|
30
|
27
|
}
|
|
31
|
28
|
|
|
32
|
|
- public boolean matches(String method)
|
|
33
|
|
- {
|
|
|
29
|
+ public boolean matches(String method) {
|
|
34
|
30
|
return (this == resolve(method));
|
|
35
|
31
|
}
|
|
36
|
32
|
}
|