This commit is contained in:
@@ -159,7 +159,10 @@ def _join_paths(base: str, sub: str) -> str:
|
||||
|
||||
|
||||
def _http_method(ann_name: str, ann: Annotation) -> str:
|
||||
"""从映射注解推断 HTTP 方法。"""
|
||||
"""从映射注解推断 HTTP 方法。
|
||||
|
||||
支持大小写不敏感匹配,避免 PUTMapping、POSTMapping 等不规范写法导致解析失败。
|
||||
"""
|
||||
mapping = {
|
||||
"GetMapping": "GET",
|
||||
"PostMapping": "POST",
|
||||
@@ -167,9 +170,11 @@ def _http_method(ann_name: str, ann: Annotation) -> str:
|
||||
"DeleteMapping": "DELETE",
|
||||
"PatchMapping": "PATCH",
|
||||
}
|
||||
if ann_name in mapping:
|
||||
return mapping[ann_name]
|
||||
if ann_name == "RequestMapping":
|
||||
# 大小写不敏感匹配
|
||||
for key, value in mapping.items():
|
||||
if key.lower() == ann_name.lower():
|
||||
return value
|
||||
if ann_name.lower() == "requestmapping":
|
||||
m = _ann_string(ann, "method")
|
||||
if m:
|
||||
return m.replace("RequestMethod.", "").upper()
|
||||
|
||||
Reference in New Issue
Block a user