mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-24 03:29:05 +08:00
dc20a86b33
fix 修复登录日志查看权限 feat 访问日志增加接口信息显示 perf 为所有orm的Insert操作增加OmitEmptyData选项
61 lines
2.1 KiB
Go
61 lines
2.1 KiB
Go
// Package consts
|
|
// @Link https://github.com/bufanyun/hotgo
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
|
// @Author Ms <133814250@qq.com>
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
package consts
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/errors/gcode"
|
|
"hotgo/internal/library/dict"
|
|
"hotgo/internal/model"
|
|
"net/http"
|
|
)
|
|
|
|
func init() {
|
|
dict.RegisterEnums("HTTPMethod", "HTTP请求方式选项", HTTPMethodOptions)
|
|
dict.RegisterEnums("HTTPHandlerTime", "HTTP处理耗时选项", HTTPHandlerTimeOptions)
|
|
dict.RegisterEnums("HTTPApiCode", "HTTP接口状态码选项", HTTPApiCodeOptions)
|
|
}
|
|
|
|
const (
|
|
HTTPContentTypeXml = "text/xml"
|
|
HTTPContentTypeHtml = "text/html"
|
|
HTTPContentTypeStream = "text/event-stream"
|
|
HTTPContentTypeJson = "application/json"
|
|
)
|
|
|
|
// HTTPMethodOptions HTTP请求方式选项
|
|
var HTTPMethodOptions = []*model.Option{
|
|
dict.GenSuccessOption(http.MethodGet, "GET"),
|
|
dict.GenInfoOption(http.MethodPost, "POST"),
|
|
dict.GenSuccessOption(http.MethodPut, "PUT"),
|
|
dict.GenInfoOption(http.MethodDelete, "DELETE"),
|
|
}
|
|
|
|
const (
|
|
HTTPHandlerTime50 = "< 50"
|
|
HTTPHandlerTime200 = "< 200"
|
|
HTTPHandlerTime200To500 = "BETWEEN 200 AND 500"
|
|
HTTPHandlerTime500To1000 = "BETWEEN 500 AND 1000"
|
|
HTTPHandlerTime1000To10000 = "BETWEEN 1000 AND 10000"
|
|
HTTPHandlerTime10000UP = "> 10000"
|
|
)
|
|
|
|
// HTTPHandlerTimeOptions HTTP处理耗时选项
|
|
var HTTPHandlerTimeOptions = []*model.Option{
|
|
dict.GenSuccessOption(HTTPHandlerTime50, "50ms以内"),
|
|
dict.GenInfoOption(HTTPHandlerTime200, "200ms以内"),
|
|
dict.GenSuccessOption(HTTPHandlerTime200To500, "200~500ms"),
|
|
dict.GenSuccessOption(HTTPHandlerTime500To1000, "500~1000ms"),
|
|
dict.GenInfoOption(HTTPHandlerTime1000To10000, "1000~10000ms"),
|
|
dict.GenInfoOption(HTTPHandlerTime10000UP, "10000ms以上"),
|
|
}
|
|
|
|
// HTTPApiCodeOptions HTTP接口状态码选项
|
|
var HTTPApiCodeOptions = []*model.Option{
|
|
dict.GenSuccessOption(gcode.CodeOK.Code(), fmt.Sprintf("%v %v", gcode.CodeOK.Code(), "成功")),
|
|
dict.GenWarningOption(gcode.CodeNil.Code(), fmt.Sprintf("%v %v", gcode.CodeNil.Code(), "失败")),
|
|
}
|