Documentation ¶
Overview ¶
Package define...
Description : define...
Author : go_developer@163.com<白茶清欢>
Date : 2021-10-09 9:37 下午
Package define...
Description : 配置解析
Author : go_developer@163.com<白茶清欢>
Date : 2021-07-25 7:57 下午
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2023-02-09 15:54
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2023-02-09 16:10
Package define ...
Author: go_developer@163.com<白茶清欢>
File: core.go
Description: core 定义核心的数据结构
Date: 2020/10/13 12:38 下午
Package define...
Description : define...
Author : go_developer@163.com<白茶清欢>
Date : 2021-10-10 10:45 下午
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2022-10-15 17:32
Package define...
Description : define...
Author : go_developer@163.com<白茶清欢>
Date : 2021-09-18 3:04 下午
Package define ...
Description : 定义日志的解析结构
Author : go_developer@163.com<白茶清欢>
Date : 14:12 2023/02/12
Package define ...
Description : mesh 相关配置
Author : go_developer@163.com<白茶清欢>
Date : 2021-09-26 5:52 下午
Package define ...
Description , 操作的枚举值 ¶
Author , go_developer@163.com<白茶清欢>
Date , 2021-10-08 5,27 下午 ¶
Package define...
Description : define...
Author : go_developer@163.com<白茶清欢>
Date : 2021-09-18 2:49 下午
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2023-02-14 10:45
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2023-02-11 19:27
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2022-10-15 01:16
Index ¶
Constants ¶
const ( // APIRetryRuleNever 不重试 APIRetryRuleNever = 0 // APIRetryRuleServerError 5xx 异常重试 APIRetryRuleServerError = 1 // APIRetryRuleBusinessError 业务码异常 APIRetryRuleBusinessError = 2 // APIRetryRuleTimeout 499 异常重试 APIRetryRuleTimeout = 3 // APIRetryRuleAll 任意异常均进行重试 APIRetryRuleAll = 4 )
const ( // BaseConfigFile 基础的配置文件 BaseConfigFile = "base.yml" // LoggerConfigFile 日志配置文件 LoggerConfigFile = "logger.yml" // DatabaseConfigFile 数据库配置文件 DatabaseConfigFile = "database.yml" // RedisConfigFile redis配置文件 RedisConfigFile = "redis.yml" // AuthConfigFile auth配置文件 AuthConfigFile = "auth.yml" // EtcdConfigFile etcd 配置文件 EtcdConfigFile = "etcd.yml" )
const ( // XForwardGatewayAppCode header里的app code XForwardGatewayAppCode = "X-Forward-Gateway-App-Code" // XForwardGatewaySign 网关的请求签名 XForwardGatewaySign = "X-Forward-Gateway-Sign" // XForwardGatewayAppSecret app code 对应的secret XForwardGatewayAppSecret = "X-Forward-Gateway-App-Secret" )
const ( // DefaultProjectConnectTimeout 默认的项目连接超时时间 DefaultProjectConnectTimeout = 500 // DefaultProjectReadTimeout 默认项目读取超时时间 DefaultProjectReadTimeout = 5000 )
const ( // RateLimitTimeGapSecond 秒 RateLimitTimeGapSecond = "SECOND" // RateLimitTimeGapMinute 分钟 RateLimitTimeGapMinute = "MINUTE" // RateLimitTimeGapHour 小时 RateLimitTimeGapHour = "HOUR" // RateLimitTimeGapDay 天 RateLimitTimeGapDay = "DAY" // RateLimitAppGlobalKeyTpl app全局的流控key模板 RateLimitAppGlobalKeyTpl = "RATE_LIMIT_GLOBAL_APP_{{APP_CODE}}_{{TIME_GAP}}" // RateLimitAppURLKeyTpl app接口流控key模板 RateLimitAppURLKeyTpl = "RATE_LIMIT_URI_{{APP_CODE}}_{{URI}}_{{TIME_GAP}}" // RateLimitProjectGlobalKeyTpl 项目全局流控 RateLimitProjectGlobalKeyTpl = "RATE_LIMIT_GLOBAL_PROJECT_{{PROJECT_ID}}_{{TIME_GAP}}" )
const ( // ParamBindRouterNo 参数不绑定到路由 ParamBindRouterNo = 0 // ParamBindRouterYes 参数需要绑定到路由 ParamBindRouterYes = 1 )
const ( // ParamIsRequiredNo 非必填 ParamIsRequiredNo = 0 // ParamIsRequiredYes 必填 ParamIsRequiredYes = 1 )
const ( // LanguageChinese 中文 LanguageChinese = "zh-cn" // LanguageEnglish 英文 LanguageEnglish = "en" )
const ( // ParamInvalid 参数非法 ParamInvalid = 400 // AuthFail 授权失败 AuthFail = 401 // ViewForbidden 禁止访问 ViewForbidden = 403 // Success 处理成功 Success = 200 // GatewaySignGenerateFail 网关签名申请失败 GatewaySignGenerateFail = 4000 // GatewaySignValidateFail 网关签名验证失败,一般由于输入非法的token导致 GatewaySignValidateFail = 4003 // GatewaySignConvertFail 签名数据转换失败 GatewaySignConvertFail = 4004 // GatewayParamTypeCheckFail 网关参数类型检测失败 GatewayParamTypeCheckFail = 4005 // GatewayParamGroupNotMatched 未匹配任何参数规则 GatewayParamGroupNotMatched = 4006 // GatewayProxyRequestFail 代理向后请求数据失败 GatewayProxyRequestFail = 4007 // GatewayAppGlobalPerSecondUseUp 网关应用全局的每秒限流令牌已耗尽 GatewayAppGlobalPerSecondUseUp = 4008 // GatewayAppGlobalPerMinuteUseUp 网关应用全局的每分钟限流令牌已耗尽 GatewayAppGlobalPerMinuteUseUp = 4009 // GatewayAppGlobalPerHourUseUp 网关应用全局的每小时限流令牌已耗尽 GatewayAppGlobalPerHourUseUp = 4010 // GatewayAppGlobalPerDayUseUp 网关应用全局的每天限流令牌已耗尽 GatewayAppGlobalPerDayUseUp = 4011 // GatewayProxyProjectParamNotFail 项目参数必传, 但是不存在 GatewayProxyProjectParamNotFail = 4012 // GatewayProxyThirdServiceRequestFail 第三方服务请求出现异常 GatewayProxyThirdServiceRequestFail = 4013 // GatewayProxyThirdServiceResponseBodyReadFail 第三方服务响应体读取失败 GatewayProxyThirdServiceResponseBodyReadFail = 4014 // GatewayProxyResultFilterFail 请求结果过滤失败 GatewayProxyResultFilterFail = 4015 // GatewayProjectGlobalPerSecondUseUp 项目每秒流量已耗尽 GatewayProjectGlobalPerSecondUseUp = 4016 // GatewayProjectGlobalPerMinuteUseUp 项目的每分钟限流令牌已耗尽 GatewayProjectGlobalPerMinuteUseUp = 4017 // GatewayProjectGlobalPerHourUseUp 项目每小时流量已耗尽 GatewayProjectGlobalPerHourUseUp = 4018 // GatewayProjectGlobalPerDayUseUp 网关应用全局的每天限流令牌已耗尽 GatewayProjectGlobalPerDayUseUp = 4019 // ProjectCreateFail 创建项目失败 ProjectCreateFail = 100001 // ProjectDeleteFail 删除项目失败 ProjectDeleteFail = 100002 // ProjectModifyFail 项目修改失败 ProjectModifyFail = 100003 // ProjectStatusChangeFail 项目状态变更失败 ProjectStatusChangeFail = 100004 // ProjectListFetchFail 查询项目列表失败 ProjectListFetchFail = 100005 // ProjectDetailFetchFail 查询项目详情失败 ProjectDetailFetchFail = 100006 // ProjectChangeDoNothing 项目未做任何变更 ProjectChangeDoNothing = 100007 // ProjectCountFetchFail 项目数量获取失败 ProjectCountFetchFail = 100008 // ProjectNotFound 项目不存在 ProjectNotFound = 100009 // ProjectAlreadyExist 项目标识已存在 ProjectAlreadyExist = 100010 // LogCreateFail 操作日志记录失败 LogCreateFail = 200001 // LogListFetchFail 日志列表获取失败 LogListFetchFail = 200002 // LogCountFetchFail 日志数量获取失败 LogCountFetchFail = 200003 // SystemEventCreateFail 系统事件记录创建失败 SystemEventCreateFail = 200004 // SystemEventListFetchFail 系统事件列表获取失败 SystemEventListFetchFail = 200005 // SystemEventDetailFetchFail 系统事件详情获取失败 SystemEventDetailFetchFail = 200006 // SystemEventCountFetchFail 系统事件数量获取失败 SystemEventCountFetchFail = 200007 // SystemEventNotFound 系统事件不存在 SystemEventNotFound = 200008 // SystemEventReceiveListFetchFail 事件接收列表获取失败 SystemEventReceiveListFetchFail = 200009 // SystemEventReceiveDetailFetchFail 系统事件接收详情获取失败 SystemEventReceiveDetailFetchFail = 200010 // SystemEventReceiveCountFetchFail 系统事件数量获取失败 SystemEventReceiveCountFetchFail = 200011 // SystemEventReceiveDetailNotFound 系统事件不存在 SystemEventReceiveDetailNotFound = 200012 // ProjectApiCreateFail 项目api创建失败 ProjectApiCreateFail = 300001 // ProjectApiDeleteFail 项目api删除失败 ProjectApiDeleteFail = 300002 // ProjectApiListFetchFail 项目api列表获取失败 ProjectApiListFetchFail = 300003 // ProjectApiDetailFetchFail 项目api详细信息获取失败 ProjectApiDetailFetchFail = 300004 // ProjectApiCountFetchFail 项目 api 数量获取失败 ProjectApiCountFetchFail = 300005 // ProjectApiStatusChangeFail 项目api状态变更失败 ProjectApiStatusChangeFail = 300006 // ProjectApiModifyFail 项目api信息修改失败 ProjectApiModifyFail = 300007 // ProjectApiParamListFetchFail 项目api参数列表获取失败 ProjectApiParamListFetchFail = 300008 // ProjectApiParamCreateFail 项目api参数创建失败 ProjectApiParamCreateFail = 300009 // ProjectApiResultListFetchFail 项目接口信息获取失败 ProjectApiResultListFetchFail = 300010 // ProjectApiResultCreateFail 项目api结果创建失败 ProjectApiResultCreateFail = 300011 // ProjectApiNotFound 项目接口不存在 ProjectApiNotFound = 300012 // ProjectApiAlreadyExist 项目接口已存在 ProjectApiAlreadyExist = 300013 // HttpConfigSchemeListFetchFail scheme 列表获取失败 HttpConfigSchemeListFetchFail = 400001 // HttpConfigMethodListFetchFail method 列表获取失败 HttpConfigMethodListFetchFail = 400002 // HttpConfigContentTypeListFetchFail content type 列表获取失败 HttpConfigContentTypeListFetchFail = 400003 // HttpConfigContentTypeNotFound 配置类型不存在 HttpConfigContentTypeNotFound = 400004 // HttpConfigSchemeNotFound 请求协议配置不存在 HttpConfigSchemeNotFound = 400005 // HttpConfigMethodNotFound 请求方法配置不存在 HttpConfigMethodNotFound = 400006 // HttpConfigMethodStatusInvalid 方法状态非法 HttpConfigMethodStatusInvalid = 400007 // HttpConfigContentTypeStatusInvalid content type 状态非法 HttpConfigContentTypeStatusInvalid = 400008 // HttpConfigSchemeStatusInvalid 状态非法 HttpConfigSchemeStatusInvalid = 400009 // GatewayApiCreateFail 网关api创建失败 GatewayApiCreateFail = 500001 // GatewayApiDetailFetchFail 网关接口详情获取失败 GatewayApiDetailFetchFail = 500002 // GatewayApiModifyFail 网关接口修改失败 GatewayApiModifyFail = 500003 // GatewayApiChangeDoNothing 网关接口未做任何修改 GatewayApiChangeDoNothing = 500004 // GatewayApiListFetchFail 网关接口列表获取失败 GatewayApiListFetchFail = 500005 // GatewayApiCuntFetchFail 网关接口数量获取失败 GatewayApiCuntFetchFail = 500006 // GatewayApiParamCreateFail 网关接口参数创建失败 GatewayApiParamCreateFail = 500007 // GatewayApiParamListFetchFail 网关接口参数列表读取失败 GatewayApiParamListFetchFail = 500008 // GatewayApiResultCreateFail 网关交口结果创建失败 GatewayApiResultCreateFail = 500009 // GatewayApiResultListFetchFail 网关接口结果列表获取失败 GatewayApiResultListFetchFail = 500010 // GatewayApiResultInputExampleFormatError 网关结果输入的示例数据解析异常 GatewayApiResultInputExampleFormatError = 500011 // GatewayApiNotFound 网关接口不存在 GatewayApiNotFound = 500012 // GatewayApiStatusInvalid 网关接口状态异常 GatewayApiStatusInvalid = 500013 // AppCreateFail app 创建失败 AppCreateFail = 600000 // AppDetailFetchFail app详细信息获取失败 AppDetailFetchFail = 600001 // AppUpdateFail app 更新失败 AppUpdateFail = 600002 // AppListFetchFail app 列表拉取失败 AppListFetchFail = 600003 // AppCountFetchFail 应用数量获取失败 AppCountFetchFail = 600004 // AppDetailNotFound 应用信息不存在 AppDetailNotFound = 600005 // AppStatusInvalid 应用状态异常 AppStatusInvalid = 600006 // AppApiPermissionCreateFail 应用接口权限创建失败 AppApiPermissionCreateFail = 600007 // AppApiPermissionListFetchFail 授权列表获取失败 AppApiPermissionListFetchFail = 600008 // AppApiPermissionCountFetchFail 获取数量失败 AppApiPermissionCountFetchFail = 600009 // AppApiPermissionDetailFetchFail 应用接口授权读取失败 AppApiPermissionDetailFetchFail = 600010 // AppApiPermissionDetailNotFound 应用接口授权不存在 AppApiPermissionDetailNotFound = 600011 // AppApiPermissionDeleteFail 应用接口授权移除失败 AppApiPermissionDeleteFail = 600012 // AppApiPermissionNothingChanged 未做任何修改 AppApiPermissionNothingChanged = 600013 // AppApiPermissionUpdateFail 应用接口权限 AppApiPermissionUpdateFail = 600014 // AppApiPermissionAlreadyExist 应用接口权限已存在 AppApiPermissionAlreadyExist = 600015 // UserRoleCreateFail 用户角色创建失败 UserRoleCreateFail = 700001 // UserCreateFail 用户创建失败 UserCreateFail = 700002 // UserDetailFetchFail 用户详细信息获取失败 UserDetailFetchFail = 700003 // UserWaitActive 用户待激活 UserWaitActive = 700004 // UserHasBeenForbidden 用户被禁用 UserHasBeenForbidden = 700005 // UserHasBeenDelete 用户被删除 UserHasBeenDelete = 700006 // UserAccountOrPasswordError 账号或密码错误 UserAccountOrPasswordError = 700007 // UserPasswordError 密码错误 UserPasswordError = 700008 // UserTokenGenerateFail 用户token生成失败 UserTokenGenerateFail = 700009 // UserTokenClientIpNotMatched 用户IP发生变化 UserTokenClientIpNotMatched = 700010 // UserEnvHasBeenChanged 用户UA发生变化 UserEnvHasBeenChanged = 700011 // UserTokenHasExpired 用户token已过期 UserTokenHasExpired = 700012 // UserTokenValidateFail token验证失败 UserTokenValidateFail = 700013 // UserListFetchFail 用户列表获取失败 UserListFetchFail = 700014 // UserCountFetchFail 用户数量获取失败 UserCountFetchFail = 700015 // UserTokenListFetchFail 用户token列表获取失败 UserTokenListFetchFail = 700016 // UserTokenCountFetchFail 用户token数量获取失败 UserTokenCountFetchFail = 700017 // UserTokenObsoleteFail 用户token作废失败 UserTokenObsoleteFail = 700018 // UserRoleListFetchFail 用户角色列表拉取失败 UserRoleListFetchFail = 700019 // UserRoleDetailFetchFail 用户角色详情获取失败 UserRoleDetailFetchFail = 700020 // UserRoleNothingChanged 用户角色无需修改任何数据 UserRoleNothingChanged = 700021 // UserRoleModifyFail 用户角色修改失败 UserRoleModifyFail = 700022 // UserModifyFail 用户修改失败 UserModifyFail = 700023 // UserNothingBeModified 用户没有被修改 UserNothingBeModified = 700024 // UserRolePermissionListFetchFail 用户角色权限获取失败 UserRolePermissionListFetchFail = 700025 // UserRolePermissionChangeFail 用户角色权限变更失败 UserRolePermissionChangeFail = 700026 // UserRoleNotFound 用户角色不存在 UserRoleNotFound = 700027 // UserNotFound 用户不存在 UserNotFound = 700028 // AdminApiCreateFail 接口创建失败 AdminApiCreateFail = 700050 // AdminApiListFetchFail 接口列表查询失败 AdminApiListFetchFail = 700051 // AdminApiDetailFetchFail 管理接口详情获取失败 AdminApiDetailFetchFail = 700052 // AdminApiDetailNotFound 管理接口不存在 AdminApiDetailNotFound = 700053 // AdminApiSonListFetchFail 子路由功能获取失败 AdminApiSonListFetchFail = 700054 // AdminApiNothingUpdate 管理接口api无需任何更新 AdminApiNothingUpdate = 700055 // AdminApiSonListChangeFail 子节点变更失败 AdminApiSonListChangeFail = 700056 // AdminApiUpdateFail 管理接口API更新失败 AdminApiUpdateFail = 700057 )
const ( // FilterAppPermission app权限验证 FilterAppPermission = "app_permission" // FilterRequestThirdService 请求第三方服务 FilterRequestThirdService = "request_third_service" // FilterCheckRequest 校验请求 FilterCheckRequest = "check_request" // FilterParseGatewayRequest 解析网关请求 FilterParseGatewayRequest = "parse_gateway_request" // FilterInitRequestContext 初始化请求上下文 FilterInitRequestContext = "init_request_context" // FilterParseGatewayApiInfo 解析网关接口信息 FilterParseGatewayApiInfo = "parse_gateway_api_info" // FilterInitProjectInfo 初始化网关项目信息 FilterInitProjectInfo = "init_project_info" // FilterInitProjectApiInfo 初始化项目接口信息 FilterInitProjectApiInfo = "init_project_api_info" // FilterInitGatewayApiInfo 初始化网关接口信息 FilterInitGatewayApiInfo = "init_gateway_api_info" // FilterInitGatewayApiParamRule 初始化网关接口参数 FilterInitGatewayApiParamRule = "init_gateway_api_param_rule" // FilterInitProjectApiParam 初始化项目API参数 FilterInitProjectApiParam = "init_project_api_param" FilterInitGatewayApiResult = "init_gateway_api_result" // FilterRateLimit 流控的处理 FilterRateLimit = "rate_limit" // FilterBuildBackendRequest 构建对后端服务的请求 FilterBuildBackendRequest = "build_backend_request" // FilterValidateGatewayParam 验证网关请求参数 FilterValidateGatewayParam = "validate_gateway_param" // FilterGatewayResponseData 网关响应数据 FilterGatewayResponseData = "gateway_response_data" // FilterValidateAuth 验证访问身份 FilterValidateAuth = "validate_auth" // FilterValidateAppApiPermission 验证网关接口权限 FilterValidateAppApiPermission = "validate_app_api_permission" )
const ( // OperateCreateProject 创建项目 OperateCreateProject = "CREATE_PROJECT" // OperateModifyProjectInfo 修改项目信息 OperateModifyProjectInfo = "MODIFY_PROJECT_INFO" // OperateModifyProjectStatus 修改项目状态 OperateModifyProjectStatus = "MODIFY_PROJECT_STATUS" // OperateCreateProjectApi 创建project_api OperateCreateProjectApi = "CREATE_PROJECT_API" // OperateTypeCreateProjectApiParam 新建project_api参数 OperateTypeCreateProjectApiParam = "CREATE_PROJECT_API_PARAM" // OperateModifyProjectApiStatus 修改api状态 OperateModifyProjectApiStatus = "MODIFY_PROJECT_API_STATUS" // OperateModifyProjectApiInfo 修改project_api信息 OperateModifyProjectApiInfo = "MODIFY_PROJECT_API_INFO" // OperateTypeCreateProjectApiResult 创建项目API返回结果 OperateTypeCreateProjectApiResult = "CREATE_PROJECT_API_RESULT" // OperateTypeModifyProjectApiResult 修改项目API返回结果 OperateTypeModifyProjectApiResult = "MODIFY_PROJECT_API_RESULT" // OperateTypeModifyProjectApiResultStatus 修改状态 OperateTypeModifyProjectApiResultStatus = "MODIFY_PROJECT_API_RESULT_STATUS" // OperateTypeForbiddenProjectApiResult 禁用项目API返回结果 OperateTypeForbiddenProjectApiResult = "FORBIDDEN_PROJECT_API_RESULT" // OperateTypeCreateAPP 创建app OperateTypeCreateAPP = "CREATE_APP" // OperateTypeModifyAPPStatus 修改app状态 OperateTypeModifyAPPStatus = "MODIFY_APP_STATUS" // OperateTypeModifyAPPInfo 修改app数据 OperateTypeModifyAPPInfo = "MODIFY_APP_INFO" // OperateTypeCreateAppApiPermission 增加应用授权 OperateTypeCreateAppApiPermission = "CREATE_APP_API_PERMISSION" // OperateTypeModifyAppApiPermission 修改应用授权 OperateTypeModifyAppApiPermission = "MODIFY_APP_API_PERMISSION" // OperateTypeDeleteAppApiPermission 删除应用授权 OperateTypeDeleteAppApiPermission = "DELETE_APP_API_PERMISSION" // OperateTypeCreateGatewayAPI 创建网关API OperateTypeCreateGatewayAPI = "CREATE_GATEWAY_API" // OperateTypeModifyGatewayAPIInfo 修改网关API信息 OperateTypeModifyGatewayAPIInfo = "MODIFY_GATEWAY_API_INFO" // OperateTypeCreateGatewayApiParam 创建网关api参数 OperateTypeCreateGatewayApiParam = "CREATE_GATEWAY_API_PARAM" // OperateTypeCreateGatewayApiResult 创建网关返回值 OperateTypeCreateGatewayApiResult = "CREATE_GATEWAY_API_RESULT" // OperateTypeModifyGatewayApiStatus 修改网关api状态 OperateTypeModifyGatewayApiStatus = "MODIFY_GATEWAY_API_STATUS" // OperateTypeCreateUser 创建用户 OperateTypeCreateUser = "CREATE_USER" // OperateTypeActiveUser 激活用户 OperateTypeActiveUser = "ACTIVE_USER" // OperateTypeForbiddenUser 封禁用户 OperateTypeForbiddenUser = "FORBIDDEN_USER" // OperateTypeDeleteUser 删除用户 OperateTypeDeleteUser = "DELETE_USER" // OperateTypeModifyUser 修改用户 OperateTypeModifyUser = "MODIFY_USER" // OperateTypeResetUserPassword 重置用户密码 OperateTypeResetUserPassword = "RESET_USER_PASSWORD" // OperateTypeUserApiEnable 云讯通过接口访问 OperateTypeUserApiEnable = "USER_API_ENABLE" // OperateTypeUserApiDisable 禁止通过接口访问 OperateTypeUserApiDisable = "USER_API_DISABLE" // OperateTypeCreateUserRole 创建用户角色 OperateTypeCreateUserRole = "CREATE_USER_ROLE" // OperateTypeModifyUserRole 修改用户角色 OperateTypeModifyUserRole = "MODIFY_USER_ROLE" // OperateTypeDeleteUserRole 删除用户角色 OperateTypeDeleteUserRole = "DELETE_USER_ROLE" // OperateTypeForbiddenUserRole 禁用用户角色 OperateTypeForbiddenUserRole = "FORBIDDEN_USER_ROLE" // OperateTypeChangeUserRolePermission 修改角色权限 OperateTypeChangeUserRolePermission = "CHANGE_USER_ROLE_PERMISSION" // OperateTypeAdminApiModify 修改管理后台接口 OperateTypeAdminApiModify = "ADMIN_API_MODIFY" // OperateTypeAdminApiForbidden 禁用管理后台接口 OperateTypeAdminApiForbidden = "ADMIN_API_FORBIDDEN" // OperateTypeAdminApiOffline 下线管理后台接口 OperateTypeAdminApiOffline = "ADMIN_API_OFFLINE" // OperateTypeAdminApiEnable 启用接口 OperateTypeAdminApiEnable = "ADMIN_API_ENABLE" // OperateTypeAdminObsoleteToken 管理员作废token OperateTypeAdminObsoleteToken = "ADMIN_OBSOLETE_TOKEN" // OperateTypeAdminApiCreate 创建管理后台接口 OperateTypeAdminApiCreate = "ADMIN_API_CREATE" // OperateTypeUserRoleForbidden 禁用用户角色 OperateTypeUserRoleForbidden = "USER_ROLE_FORBIDDEN" // OperateTypeUserRoleDelete 删除角色 OperateTypeUserRoleDelete = "USER_ROLE_DELETE" // OperateTypeUserRoleEnable 启用角色 OperateTypeUserRoleEnable = "USER_ROLE_ENABLE" )
const ( // RequestParameterAppCode 请求的app_code参数名 RequestParameterAppCode = "app_code" // RequestTraceID 请求的trace_id RequestTraceID = "trace_id" // RequestStartTime 请求开始时间 RequestStartTime = "start_time" )
const ( // ParseLoginUserIDField 登录的用户ID ParseLoginUserIDField = "login_user_id" // ParseLoginUserRoleIDField 用户角色ID ParseLoginUserRoleIDField = "login_user_role_id" // ParseLoginUserDetailField 登陆的用户详情 ParseLoginUserDetailField = "login_user_detail" // ParseViewUriIDField 正在访问的接口ID ParseViewUriIDField = "view_uri_id" // ParseViewUriValidateTokenField 接口是否验证登录 ParseViewUriValidateTokenField = "view_uri_validate_token" // ParseUserOperateModeField 用户操作模式 0 - PC后台 1 - 接口API ParseUserOperateModeField = "user_operate_mode" // XFrontAuthorization header中authorization的key XFrontAuthorization = "X-Front-Authorization" )
const ( // DefaultPage ... DefaultPage = 1 // DefaultSize ... DefaultSize = 20 )
const ( // MaxSignEffectiveTime 签名最长有效期 1 小时 MaxSignEffectiveTime = 3600 // DefaultEffectiveTime 未指定时默认的签名有效期 1 分钟 DefaultEffectiveTime = 60 )
const ( // ActionParseServiceInfo 解析服务信息 ActionParseServiceInfo = "PARSE_SERVICE_INFO" // ActionGetProjectDetail 读取项目详情 ActionGetProjectDetail = "GET_PROJECT_DETAIL" // ActionGetApiRouter 获取接口路由 ActionGetApiRouter = "GET_API_ROUTER" // ActionRequestForward 请求代理 ActionRequestForward = "REQUEST_FORWARD" // ActionExecuteFilter 执行过滤器 ActionExecuteFilter = "EXECUTE_FILTER" // ActionExecuteFilterItemTpl 具体执行的过滤器 ActionExecuteFilterItemTpl = "EXECUTE_FILTER_ITEM_%s" // ActionParseGatewayAppInfo 解析网关的app信息 ActionParseGatewayAppInfo = "PARSE_GATEWAY_APP_INFO" )
const (
// XGatewayForwardHeaderPrefix 网关向后转发的header前缀
XGatewayForwardHeaderPrefix = "x-gateway-forward-header-"
)
Variables ¶
var ( // DBMap ... DBMap = []CommonStringDesc{ {"", "全部"}, {defineDao.DBTableAPP, "app信息表"}, {defineDao.DBTableAppApiPermission, "app授权信息表"}, {defineDao.DBTableProject, "项目信息表"}, {defineDao.DBTableProjectApi, "项目API信息表"}, {defineDao.DBTableProjectApiParam, "项目API参数信息表"}, {defineDao.DBTableProjectApiResult, "项目API返回值信息表"}, {defineDao.DBTableLog, "日志信息表"}, {defineDao.DBTableMeshAPI, "Mesh API信息表"}, {defineDao.DBTableMeshAPIConfig, "Mesh API配置表"}, {defineDao.DBTableMeshAPIResult, "Mesh API结果配置表"}, {defineDao.DBTableMethod, "请求方法信息表"}, {defineDao.DBTableScheme, "请求协议信息表"}, {defineDao.DBTableContentType, "请求类型信息表"}, {defineDao.DBTableGatewayApi, "网关API信息表"}, {defineDao.DBTableGatewayApiParam, "网关API请求参数表"}, {defineDao.DBTableGatewayApiResult, "网关API返回值信息表"}, {defineDao.DBTableUser, "用户信息表"}, {defineDao.DBTableUserRole, "用户角色信息表"}, {defineDao.DBTableUserRolePermission, "用户角色权限信息表"}, {defineDao.DBTableAdminApi, "后台接口信息表"}, {defineDao.DBTableUserToken, "用户登录信息表"}, {defineDao.DBTableSystemEvent, "系统事件发送表"}, {defineDao.DBTableSystemEventReceiveLog, "系统事件接收表"}, } )
var ( // DatabaseFieldTable 数据库字段表 DatabaseFieldTable = []CommonStringDesc{ {"name", "名称"}, {"id", "主键ID"}, {"description", "描述"}, {"status", "状态"}, {"scheme_id", "请求协议"}, {"project_id", "项目ID"}, {"api_id", "API ID"}, {"create_time", "创建时间"}, {"modify_time", "修改时间"}, {"modify_user_id", "修改人ID"}, {"create_user_id", "创建人ID"}, {"flag", "项目标识"}, {"domain", "服务域名"}, {"port", "服务端口"}, {"code_field", "业务状态码字段"}, {"message_field", "业务状态码描述字段"}, {"data_field", "业务数据字段"}, {"success_field", "代表请求成功的状态码"}, {"uri", "网关对外的uri"}, {"map_uri", "后端真实服务URI"}, {"content_type_id", "网关API请求类型"}, {"backend_method_id", "后端接口请求方法"}, {"backend_content_type_id", "后端接口请求方式"}, {"retry_cnt", "请求失败重试次数"}, {"retry_interval", "重试的时间间隔"}, {"retry_rule", "重试规则"}, {"param_type", "参数类型"}, {"bind_route", "参数是否绑定到路由"}, {"backend_param_name", "后端服务接受的参数名"}, {"is_required", "是否必填"}, {"default_value", "默认值"}, {"example_value", "示例参数值"}, {"code", "应用code"}, {"secret", "应用密钥"}, {"apply_user_name", "申请人姓名"}, {"apply_user_contact", "申请人联系方式"}, } )
var ( // EventTypeTable 事件类型表 EventTypeTable = []CommonStringDesc{ {event.TypeAppCreate, "创建应用"}, {event.TypeAppModify, "修改应用"}, {event.TypeAppChangeStatus, "变更应用状态"}, {event.TypeProjectCreate, "创建项目"}, {event.TypeProjectModify, "修改项目"}, {event.TypeProjectChangeStatus, "变更项目状态"}, {event.TypeProjectApiCreate, "创建项目接口"}, {event.TypeProjectApiModify, "修改项目接口"}, {event.TypeProjectApiChangeStatus, "变更项目接口状态"}, {event.TypeProjectApiParamCreate, "创建项目接口参数"}, {event.TypeProjectApiParamModify, "修改项目接口参数"}, {event.TypeProjectApiParamChangeStatus, "变更项目接口参数状态"}, {event.TypeProjectApiResultCreate, "创建项目接口返回值"}, {event.TypeProjectApiResultModify, "修改项目接口返回值"}, {event.TypeProjectApiResultChangeStatus, "变更项目接口返回值状态"}, {event.TypeGatewayApiCreate, "创建网关接口"}, {event.TypeGatewayApiModify, "修改网关接口"}, {event.TypeGatewayApiChangeStatus, "变更网关接口状态"}, {event.TypeGatewayApiParamCreate, "创建网关接口参数"}, {event.TypeGatewayApiParamModify, "修改网关接口参数"}, {event.TypeGatewayApiParamChangeStatus, "变更网关接口参数状态"}, {event.TypeGatewayApiResultCreate, "创建网关接口返回值"}, {event.TypeGatewayApiResultModify, "修改网关接口返回值"}, {event.TypeGatewayApiResultChangeStatus, "变更网关接口返回值状态"}, {event.TypeSchemeCreate, "创建通信协议"}, {event.TypeSchemeModify, "修改通信协议"}, {event.TypeSchemeChangeStatus, "变更通信协议状态"}, {event.TypeMethodCreate, "创建请求方法"}, {event.TypeMethodModify, "修改请求方法"}, {event.TypeMethodChangeStatus, "变更请求方法状态"}, {event.TypeContentTypeCreate, "创建请求类型"}, {event.TypeContentTypeModify, "修改请求类型"}, {event.TypeContentTypeChangeStatus, "变更请求类型状态"}, {event.TypeAppApiPermissionCreate, "增加应用接口授权"}, {event.TypeAppApiPermissionModify, "修改应用接口授权"}, {event.TypeAppApiPermissionDelete, "删除应用接口授权"}, } )
var ( // OperateTable 操作行为表 OperateTable = []CommonStringDesc{ {"", "全部"}, {OperateCreateProject, "创建项目"}, {OperateModifyProjectInfo, "更新项目详细信息"}, {OperateModifyProjectStatus, "更新项目状态"}, {OperateCreateProjectApi, "创建项目API"}, {OperateTypeCreateProjectApiParam, "新增API参数"}, {OperateModifyProjectApiStatus, "变更API状态"}, {OperateModifyProjectApiInfo, "修改API信息"}, {OperateTypeCreateAPP, "创建APP"}, {OperateTypeModifyAPPStatus, "修改app状态"}, {OperateTypeModifyAPPInfo, "修改app信息"}, {OperateTypeCreateAppApiPermission, "增加应用授权"}, {OperateTypeModifyAppApiPermission, "修改应用授权"}, {OperateTypeDeleteAppApiPermission, "删除应用授权"}, {OperateTypeCreateGatewayAPI, "创建网关API"}, {OperateTypeModifyGatewayAPIInfo, "修改网关API信息"}, {OperateTypeCreateProjectApiResult, "创建项目API返回结果"}, {OperateTypeModifyProjectApiResult, "修改项目API返回结果"}, {OperateTypeModifyProjectApiResultStatus, "修改项目API返回结果状态"}, {OperateTypeForbiddenProjectApiResult, "禁用项目API返回结果"}, {OperateTypeCreateGatewayApiParam, "创建网关参数"}, {OperateTypeCreateGatewayApiResult, "创建网关返回值"}, {OperateTypeModifyGatewayApiStatus, "修改网关api状态"}, {OperateTypeCreateUser, "创建用户"}, {OperateTypeActiveUser, "激活用户"}, {OperateTypeForbiddenUser, "封禁用户"}, {OperateTypeDeleteUser, "删除用户"}, {OperateTypeModifyUser, "修改用户"}, {OperateTypeResetUserPassword, "重置用户密码"}, {OperateTypeUserApiEnable, "启用通过接口访问"}, {OperateTypeUserApiDisable, "禁用通过接口访问"}, {OperateTypeCreateUserRole, "创建用户角色"}, {OperateTypeModifyUserRole, "修改用户角色"}, {OperateTypeDeleteUserRole, "删除用户角色"}, {OperateTypeForbiddenUserRole, "禁用用户角色"}, {OperateTypeChangeUserRolePermission, "修改角色权限"}, {OperateTypeAdminApiCreate, "创建管理后台接口"}, {OperateTypeAdminApiModify, "修改管理后台接口"}, {OperateTypeAdminApiForbidden, "禁用管理后台接口"}, {OperateTypeAdminApiOffline, "删除管理后台接口"}, {OperateTypeAdminApiEnable, "启用管理后台接口"}, {OperateTypeAdminObsoleteToken, "管理员作废token"}, {OperateTypeUserRoleForbidden, "禁用用户角色"}, {OperateTypeUserRoleDelete, "删除角色"}, {OperateTypeUserRoleEnable, "启用角色"}, } )
var ( // ParamBindRouterTable 参数是否绑定到路由 ParamBindRouterTable = []CommonIntDesc{ {ParamBindRouterNo, "否"}, {ParamBindRouterYes, "是"}, } )
var ( // ParamIsRequiredTable 参数是否必填 ParamIsRequiredTable = []CommonIntDesc{ {ParamIsRequiredNo, "非必填"}, {ParamIsRequiredYes, "必填"}, } )
var ( // ParamTypeTable 参数类型表 ParamTypeTable = []CommonStringDesc{ {defineDao.ParamTypeString, "string"}, {defineDao.ParamTypeInt, "int"}, {defineDao.ParamTypeFloat, "float"}, {defineDao.ParamTypeStringListWithSplit, "字符串列表(按照,分割)"}, {defineDao.ParamTypeFloatListWithSplit, "float数据列表(按照,分割)"}, {defineDao.ParamTypeIntListWithSplit, "int数据列表(按照,分割)"}, {defineDao.ParamTypeFloatJsonList, "float数据列表, list直接序列化"}, {defineDao.ParamTypeIntJsonList, "int数据列表, list直接序列化"}, {defineDao.ParamTypeStringJsonList, "字符串数据列表, list直接序列化"}, {defineDao.ParamTypeJsonObject, "json序列化之后的kv(map[string]interface)"}, {defineDao.ParamTypeOther, "其它"}, } )
var ( // RetryRuleTable 重试规则表 RetryRuleTable = []CommonIntDesc{ {APIRetryRuleNever, "不重试"}, {APIRetryRuleServerError, "服务端异常(5xx)"}, {APIRetryRuleBusinessError, "请求返回状态码异常"}, {APIRetryRuleTimeout, "请求超时(499)"}, {APIRetryRuleAll, "各种异常均重试"}, } )
Functions ¶
This section is empty.
Types ¶
type CommonStringDesc ¶
CommonStringDesc 字符串的取值描述
Author : go_developer@163.com<白茶清欢>
Date : 15:05 2023/3/7
func GetEventTypeDesc ¶
func GetEventTypeDesc(eventType string) CommonStringDesc
GetEventTypeDesc 获取事件类型的描述
Author : go_developer@163.com<白茶清欢>
Date : 14:42 2023/3/12
type Gateway ¶
type Gateway struct { Port int `yml:"port"` // 监听端口 Env string `yml:"env"` // 运行环境 Domain string `yml:"domain"` // 服务于明 }
Gateway 网关配置
Author : go_developer@163.com<白茶清欢>
Date : 7:57 下午 2021/7/25
type GatewayOutputResultRule ¶
type GatewayOutputResultRule struct { GatewayOutputFieldID int64 `json:"gateway_output_field_id"` // 输出字段ID GatewayOutputPath string `json:"gateway_output_path"` // 网关输出的数据 GatewayOutputType string `json:"gateway_output_type"` // 网关输出的数据类型 ProjectApiResponseDataPath string `json:"project_api_response_data_path"` // 项目接口响应数据的路径 DefaultValue string `json:"default_value"` // 默认值 }
GatewayOutputResultRule 网关对外输出数据规则
Author : go_developer@163.com<白茶清欢>
Date : 18:34 2023/3/10
type GatewayRequestUriInfo ¶
type GatewayRequestUriInfo struct { ServiceFlag string `json:"service_flag"` // 服务标识 ServiceUri string `json:"service_uri"` // 服务下的接口 QueryParam url.Values `json:"query_param"` // query中的参数 BodyData []byte `json:"body_data"` // 请求的 body 数据 RequestMethod string `json:"request_method"` // 请求方法 : GET / POST 等 }
GatewayRequestUriInfo 网关接口请求的基础信息
Author : go_developer@163.com<白茶清欢>
Date : 17:30 2023/2/9
type HttpConfig ¶
type HttpConfig struct { Method string `json:"method"` // 请求方法 ContentType string `json:"content_type"` // 请求方式 Scheme string `json:"scheme"` // 请求协议 }
HttpConfig http 配置
Author : go_developer@163.com<白茶清欢>
Date : 10:55 2023/3/10
type LogConfig ¶
type LogConfig struct { CommonConfig logger.InputLogConfig `json:"common_config" yaml:"common_config"` // 公共配置 AccessLogName string `json:"access_log_name" yaml:"access_log_name"` // 请求日志文件名 ApiLogName string `json:"api_log_name" yaml:"api_log_name"` // API请求日志文件 BusinessLogName string `json:"business_log_name" yaml:"business_log_name"` // 业务日志记录文件名 MonitorLogName string `json:"monitor_log_name" yaml:"monitor_log_name"` // 监控日志文件名 RedisLogName string `json:"redis_log_name" yaml:"redis_log_name"` // redis日志文件名 MysqlLogName string `json:"mysql_log_name" yaml:"mysql_log_name"` // mysql日志文件名 EventLogName string `json:"event_log_name" yaml:"event_log_name"` // 事件日志 }
LogConfig 日志配置规则
Author : go_developer@163.com<白茶清欢>
Date : 14:12 2023/02/12
type MeshRoute ¶
type MeshRoute struct { MeshAPIID int64 `json:"mesh_api_id"` // mesh_api_id URI string `json:"uri"` // uri 地址(网关对外暴露的地址) Method string `json:"method"` // 请求方法(调用网关接口的请求方式) ContentType string `json:"content_type"` // 请求类型 Scheme string `json:"scheme"` // 请求scheme ProxyParamRule map[string]map[string]string `json:"proxy_param_rule"` // 向后转发的参数规则 apiID => 请求参数名 => 参数提取规则 ParamGroup [][]*Param `json:"param_group"` // 网关API支持的参数组 }
MeshRoute mesh路由的数据结构
Author : go_developer@163.com<白茶清欢>
Date : 5:54 下午 2021/9/26
type Param ¶
type Param struct { Name string `json:"name"` // 参数名 BindRouteParam bool `json:"bind_route_param"` // 是否绑定在路由上的参数 /test/:id/:name IsRequired bool `json:"is_required"` // 是否必传 DefaultValue string `json:"default_value"` // 非比传时候的默认值 MapBackendParamName string `json:"map_backend_param_name"` // 映射到后端接口的参数名 GroupID string `json:"group_id"` // 参数组ID Type string `json:"type"` // 参数类型 }
Param ...
Author : go_developer@163.com<白茶清欢>
Date : 2020/10/16 15:31:23
type RequestContext ¶
type RequestContext struct { RuntimeInstance *trace.Runtime `json:"-"` // 链路统一追踪实例 InputHttpConfig *HttpConfig `json:"input_http_config"` // 输入的请求信息 GatewayHttpConfig *HttpConfig `json:"gateway_http_config"` // 网关配置的请求信息 ProjectHttpConfig *HttpConfig `json:"project_http_config"` // 项目配置的请求信息 GatewayUrlInfo *GatewayRequestUriInfo `json:"gateway_url_info"` // 网关url信息 ProjectInfo *daoDefine.Project `json:"project_info"` // 项目信息 GatewayApiInfo *daoDefine.GatewayApi `json:"gateway_api_info"` // 网关接口信息 GatewayApiParam [][]*Param `json:"gateway_api_param"` // 网关接口的参数信息(已按照配置分组) GatewayOutputResultRule []*GatewayOutputResultRule `json:"gateway_output_result_rule"` // 网关输出数据规则 AppDetail *daoDefine.App `json:"app_detail"` // 应用的详细信息 AppCode string `json:"app_code"` // 传入的APP Code Sign string `json:"sign"` // 网关接口的签名 AppSecret string `json:"app_secret"` // app code 对应的secret AppApiPermission *daoDefine.AppApiPermission `json:"app_api_permission"` // 应用接口权限 ProjectApiInfo *daoDefine.ProjectApi `json:"project_api_info"` // 项目接口信息 ProjectApiParamTable map[int64]*daoDefine.ProjectApiParam `json:"project_api_param_table"` // 项目接口参数列表 ProjectResultInfo *daoDefine.ProjectApiResult `json:"project_result_info"` // 项目接口返回信息 AllParam easymap.EasyMap `json:"all_param"` // 全部参数 BackendRequestParam map[string]interface{} `json:"backend_request_param"` // 转发到后端服务的参数 ParamGroup string `json:"param_group"` // 最终选择的参数组 BackendResponseData []byte `json:"backend_response_data"` // 后端接口返回的数据 IsCache bool `json:"is_cache"` // 是否命中缓存 IsMock bool `json:"is_mock"` // 是否使用了mock数据 }
RequestContext 请求的上下文
Author : go_developer@163.com<白茶清欢>
Date : 16:20 2023/2/9
type Response ¶
type Response struct { Code int `json:"code"` // 网关的业务码, 0 - 成功 -1 - 失败 BusinessCode string `json:"business_code"` // 业务接口返回的状态码 Message string `json:"message"` // 状态码描述 IsCache bool `json:"is_cache"` // 是否命中缓存 IsMock bool `json:"is_mock"` // 是否使用mock数据 Env string `json:"env"` // 访问的环境 Data interface{} `json:"data"` // 业务数据 }
Response 网关响应数据的数据结构
Author : go_developer@163.com<白茶清欢>
Date : 10:50 2023/2/14
type Sign ¶
type Sign struct { Uri string // 请求的接口 Method string // 接口请求方法 AppCode string // 应用 code AppSecret string // 应用secret EffectiveTime int64 // 有效时长, 纳秒时间戳 RandomFill string // 填充随机字符串, 避免外部使用规则直接构造签名 GenerateTime int64 // 签名生成时间 RemoteIP string // 申请签名的机器IP GatewayEnv string // 网关运行环境, 和服务绑定,避免多环境混用 jwt.StandardClaims // jwt 生成token }
Sign 网关请求的签名结构
Author : go_developer@163.com<白茶清欢>
Date : 19:27 2023/2/11