goProject/.svn/pristine/47/47e1f67a37d3cf0affa5dd7f1a866f5375ac5629.svn-base
2025-01-06 16:21:36 +08:00

72 lines
2.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package webServer
import (
"net/http"
"goutil/typeUtil"
)
// webserver接口
type IWebServer interface {
// 注册API
// path注册的访问路径
// callback回调方法
// configObjHandler配置对象
RegisterHandler(path string, handlerFuncObj handlerFunc, configObj *HandlerConfig)
// 注册回调-增加用户自定义数据
RegisterHandlerWithUserData(path string, handlerFuncObj handlerFunc, configObj *HandlerConfig, userData interface{})
RegisterRegexHandler(path string, handlerFuncObj handlerFunc, configObj *HandlerConfig)
// 注册正则回调-增加用户自定义数据
RegisterRegexHandlerWithUserData(path string, handlerFuncObj handlerFunc, configObj *HandlerConfig, userData interface{})
// 设定Http Header信息
SetHeader(header map[string]string)
// 设定HTTP请求方法
SetMethod(method string)
// 设定当HTTP请求方法无效时调用的处理器
SetInvalidMethodHandler(handler func(*Context))
// 设置WebServer请求是否经过了负载均衡中转
SetIfDelegate(ifDelegate bool)
// 设定默认页的处理器
SetDefaultPageHandler(handler func(*Context))
// 设定未找到指定的回调时的处理器
SetNotFoundPageHandler(handler func(*Context))
// 设置异常处理函数(默认只会记录在文件)
SetUnHandledPanicHandler(handler func(context *Context, errObj interface{}))
// 设定在Debug模式下是否需要验证IP地址
SetIfCheckIPWhenDebug(value bool)
// 设定当IP无效时调用的处理器
SetIPInvalidHandler(handler func(*Context))
// 设定用于检测参数是否有效的处理器
SetParamCheckHandler(handler func(typeUtil.MapData, []string, []string) ([]string, []string, bool))
// 设定当检测到参数无效时调用的处理器
SetParamInvalidHandler(handler func(*Context, []string, []string))
// 设定处理请求数据的处理器(例如压缩、解密等)
SetRequestDataHandler(handler func(*Context, []byte) ([]byte, error))
// 设定处理响应数据的处理器(例如压缩、加密等)
SetResponseDataHandler(handler func(*Context, []byte) ([]byte, error))
// 设定请求执行时间的处理器
SetExecuteTimeHandler(handler func(*Context))
// http应答处理
// responseWriter:应答对象
// request:请求对象
ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)
}