github.com/gofiber/fiber/v2@v2.47.0/middleware/logger/utils.go (about) 1 package logger 2 3 import ( 4 "github.com/gofiber/fiber/v2" 5 ) 6 7 func methodColor(method string, colors fiber.Colors) string { 8 switch method { 9 case fiber.MethodGet: 10 return colors.Cyan 11 case fiber.MethodPost: 12 return colors.Green 13 case fiber.MethodPut: 14 return colors.Yellow 15 case fiber.MethodDelete: 16 return colors.Red 17 case fiber.MethodPatch: 18 return colors.White 19 case fiber.MethodHead: 20 return colors.Magenta 21 case fiber.MethodOptions: 22 return colors.Blue 23 default: 24 return colors.Reset 25 } 26 } 27 28 func statusColor(code int, colors fiber.Colors) string { 29 switch { 30 case code >= fiber.StatusOK && code < fiber.StatusMultipleChoices: 31 return colors.Green 32 case code >= fiber.StatusMultipleChoices && code < fiber.StatusBadRequest: 33 return colors.Blue 34 case code >= fiber.StatusBadRequest && code < fiber.StatusInternalServerError: 35 return colors.Yellow 36 default: 37 return colors.Red 38 } 39 }