Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTimeout = HTTPTimeouts{ ReadTimeout: 10 * time.Second, ReadHeaderTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, IdleTimeout: 15 * time.Second, }
Functions ¶
Types ¶
type HTTPOption ¶
type HTTPOption func(sev *HTTPServer) error
定义一个函数类型HTTPOption,返回值是error
func WithMaxHeaderBytes ¶
func WithMaxHeaderBytes(max int) HTTPOption
func WithTimeouts ¶
func WithTimeouts(timeouts HTTPTimeouts) HTTPOption
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func StartHttpServer ¶
func StartHttpServer(addr string, handler http.Handler, opts ...HTTPOption) (*HTTPServer, error)
*
- @Description: 创建一个http services
- @param addr:监听地址
- @param handler:请求处理器,用于处理请求
- @param opts:可变响应参数
func (*HTTPServer) Addr ¶
func (hs *HTTPServer) Addr() net.Addr
func (*HTTPServer) Close ¶
func (hs *HTTPServer) Close() error
type HTTPTimeouts ¶
type WrappedResponseWriter ¶
type WrappedResponseWriter struct { StatusCode int ResponseLen int // contains filtered or unexported fields }
func NewWrappedResponseWriter ¶
func NewWrappedResponseWriter(w http.ResponseWriter) *WrappedResponseWriter
func (*WrappedResponseWriter) Header ¶
func (w *WrappedResponseWriter) Header() http.Header
func (*WrappedResponseWriter) Write ¶
func (w *WrappedResponseWriter) Write(bytes []byte) (int, error)
func (*WrappedResponseWriter) WriteHeader ¶
func (w *WrappedResponseWriter) WriteHeader(StatusCode int)
Click to show internal directories.
Click to hide internal directories.