Files
klp-oa/klp-common/src/main/java/com/klp/common/enums/HttpMethod.java

33 lines
706 B
Java
Raw Normal View History

2025-07-17 18:07:48 +08:00
package com.klp.common.enums;
2021-12-21 10:15:12 +08:00
import org.springframework.lang.Nullable;
import java.util.HashMap;
import java.util.Map;
/**
* 请求方式
*
2025-07-17 18:07:48 +08:00
* @author klp
2021-12-21 10:15:12 +08:00
*/
public enum HttpMethod {
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
static {
for (HttpMethod httpMethod : values()) {
mappings.put(httpMethod.name(), httpMethod);
}
}
@Nullable
public static HttpMethod resolve(@Nullable String method) {
return (method != null ? mappings.get(method) : null);
}
public boolean matches(String method) {
return (this == resolve(method));
}
}