-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestMethod.go
More file actions
46 lines (43 loc) · 1.37 KB
/
Copy pathrequestMethod.go
File metadata and controls
46 lines (43 loc) · 1.37 KB
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
/*
* @Author: nijineko
* @Date: 2025-06-09 13:48:25
* @LastEditTime: 2025-06-09 13:51:47
* @LastEditors: nijineko
* @Description: request method utility
* @FilePath: \noa-gin\requestMethod.go
*/
package noagin
import (
"fmt"
"github.com/noa-log/colorize"
)
/**
* @description: format request method with color
* @param {string} method HTTP request method
* @return {string} formatted request method with color
*/
func RequestMethodColor(method string) string {
RequestMethodFormatStr := " %-7s "
switch method {
case "GET":
return colorize.BlueBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "HEAD":
return colorize.MagentaBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "POST":
return colorize.CyanBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "PUT":
return colorize.BrightYellowBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "DELETE":
return colorize.RedBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "CONNECT":
return fmt.Sprintf(RequestMethodFormatStr, method)
case "OPTIONS":
return colorize.WhiteBackground(fmt.Sprintf(RequestMethodFormatStr, method))
case "TRACE":
return fmt.Sprintf(RequestMethodFormatStr, method)
case "PATCH":
return colorize.BrightGreenBackground(fmt.Sprintf(RequestMethodFormatStr, method))
default:
return fmt.Sprintf(RequestMethodFormatStr, method)
}
}