Documentation ¶
Index ¶
- Variables
- func AddressPort(address string) int
- func Bytes2str(b []byte) string
- func NewListener(address string, reuse bool) (net.Listener, error)
- func Str2bytes(s string) []byte
- type Config
- func (c *Config) AddTLSCert(certFile, keyFile string) *Config
- func (c *Config) InitListener(before ...func() error) error
- func (c *Config) InitTLSConfig(certAndKey ...string) *Config
- func (c *Config) InitTLSListener(before ...func() error) error
- func (c *Config) NewAutoTLSManager(hosts ...string) *autocert.Manager
- func (c *Config) Print(engine string)
- func (c *Config) SetListener(ln net.Listener) *Config
- func (c *Config) SupportAutoTLS(autoTLSManager *autocert.Manager, hosts ...string) *Config
- type Engine
- type Handler
- type HandlerFunc
- type Header
- type Request
- type Response
- type URL
- type URLValuer
Constants ¶
This section is empty.
Variables ¶
View Source
var (
HeaderSetCookie = `Set-Cookie`
)
Functions ¶
func AddressPort ¶ added in v1.3.9
func NewListener ¶ added in v1.3.0
Types ¶
type Config ¶
type Config struct { Address string // TCP address to listen on. Listener net.Listener // Custom `net.Listener`. If set, server accepts connections on it. ReusePort bool TLSAuto bool TLSHosts []string TLSEmail string TLSCacheDir string TLSConfig *tls.Config TLSCertFile string // TLS certificate file path. TLSKeyFile string // TLS key file path. DisableHTTP2 bool // Disables HTTP/2. ReadTimeout time.Duration // Maximum duration before timing out read of the request. WriteTimeout time.Duration // Maximum duration before timing out write of the response. MaxConnsPerIP int MaxRequestsPerConn int MaxRequestBodySize int }
Config defines engine configuration.
func (*Config) AddTLSCert ¶ added in v1.3.0
func (*Config) InitListener ¶ added in v1.3.0
func (*Config) InitTLSConfig ¶ added in v1.3.0
func (*Config) InitTLSListener ¶ added in v1.3.0
func (*Config) NewAutoTLSManager ¶ added in v1.4.3
type Handler ¶
Handler defines an interface to server HTTP requests via `ServeHTTP(Request, Response)` function.
type HandlerFunc ¶
HandlerFunc is an adapter to allow the use of `func(Request, Response)` as HTTP handlers.
func (HandlerFunc) ServeHTTP ¶
func (h HandlerFunc) ServeHTTP(req Request, res Response)
ServeHTTP serves HTTP request.
type Header ¶
type Header interface { // Add adds the key, value pair to the header. It appends to any existing values // associated with key. Add(string, string) // Del deletes the values associated with key. Del(string) // Get gets the first value associated with the given key. If there are // no values associated with the key, Get returns "". Get(string) string // Set sets the header entries associated with key to the single element value. // It replaces any existing values associated with key. Set(string, string) Object() interface{} Std() http.Header }
Header defines an interface for HTTP header.
type Request ¶
type Request interface { // Scheme returns the HTTP protocol scheme, `http` or `https`. Scheme() string // Host returns HTTP request host. Per RFC 2616, this is either the value of // the `Host` header or the host name given in the URL itself. Host() string // SetHost sets the host of the request. SetHost(string) // URI returns the unmodified `Request-URI` sent by the client. URI() string // SetURI sets the URI of the request. SetURI(string) // URL returns `engine.URL`. URL() URL // Header returns `engine.Header`. Header() Header // Proto returns the HTTP proto. (HTTP/1.1 etc.) Proto() string // RemoteAddress returns the client's network address. RemoteAddress() string // RealIP returns the client's network address based on `X-Forwarded-For` // or `X-Real-IP` request header. RealIP() string // Method returns the request's HTTP function. Method() string // SetMethod sets the HTTP method of the request. SetMethod(string) // Body returns request's body. Body() io.ReadCloser SetBody(io.Reader) // FormValue returns the form field value for the provided name. FormValue(string) string Object() interface{} Form() URLValuer PostForm() URLValuer // MultipartForm returns the multipart form. MultipartForm() *multipart.Form // IsTLS returns true if HTTP connection is TLS otherwise false. IsTLS() bool Cookie(string) string Referer() string // UserAgent returns the client's `User-Agent`. UserAgent() string // FormFile returns the multipart form file for the provided name. FormFile(string) (multipart.File, *multipart.FileHeader, error) // Size returns the size of request's body. Size() int64 BasicAuth() (string, string, bool) StdRequest() *http.Request }
Request defines an interface for HTTP request.
type Response ¶
type Response interface { // Header returns `engine.Header` Header() Header // WriteHeader sends an HTTP response header with status code. WriteHeader(int) KeepBody(bool) // Write writes the data to the connection as part of an HTTP reply. Write([]byte) (int, error) // Status returns the HTTP response status. Status() int // Size returns the number of bytes written to HTTP response. Size() int64 // Committed returns true if HTTP response header is written, otherwise false. Committed() bool // SetWriter sets the HTTP response writer. SetWriter(io.Writer) // Write returns the HTTP response writer. Writer() io.Writer Object() interface{} Hijack(func(net.Conn)) Body() []byte Redirect(string, int) NotFound() SetCookie(*http.Cookie) ServeFile(string) Stream(func(io.Writer) bool) Error(string, ...int) StdResponseWriter() http.ResponseWriter }
Response defines an interface for HTTP response.
Click to show internal directories.
Click to hide internal directories.