Documentation ¶
Index ¶
- Variables
- func AddFormData(app *App, Remote string, buf []byte, c gnet.Conn) gnet.Action
- func AddToConnectionQueue(app *App, Remote string, BoundaryName string, req *Request, res *Response, ...)
- func Byte2String(b byte) string
- func Bytes2String(b []byte) string
- func BytesCombine2(pBytes ...[]byte) []byte
- func ContainsInSlice(items []string, item string) bool
- func GenerateCookies(res *Response)
- func GetErrPage(req *Request, res *Response, err string, errCode int)
- func ParseCookies(req *Request)
- func Run(app *App) error
- func SetErrPage(errCode int, function func(*Request, *Response, string, int))
- func String2Slice(s string) (b []byte)
- func Time2HttpDate() string
- type App
- type Config
- type Connection
- type Cookie
- type FormData
- type Request
- type Response
- func (res *Response) AddCookie(cookie *Cookie)
- func (res *Response) GetBody() []byte
- func (res *Response) GetHeader(name string) []string
- func (res *Response) GetHeaders() map[string][]string
- func (res *Response) GetRaw() []byte
- func (res *Response) PushBody(content []byte)
- func (res *Response) PushBodyEnd()
- func (res *Response) RemoveHeader(name string, content string) string
- func (res *Response) SetBody(body []byte)
- func (res *Response) SetCode(code int)
- func (res *Response) SetContentType(contentType string)
- func (res *Response) SetHeader(name string, content string) string
- func (res *Response) SetJson(data any) error
- func (res *Response) SetText(text string)
- func (res *Response) String() string
- type Router
Constants ¶
This section is empty.
Variables ¶
View Source
var Code = map[int]string{
100: "Continue",
101: "Switching Protocols",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
306: "Unused",
307: "Temporary Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request Time-out",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Request Entity Too Large",
414: "Request-URI Too Large",
415: "Unsupported Media Type",
416: "Requested range not satisfiable",
417: "Expectation Failed",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Time-out",
505: "HTTP Version not supported",
}
Functions ¶
func AddFormData ¶
func AddToConnectionQueue ¶
func Byte2String ¶
func Bytes2String ¶
func BytesCombine2 ¶
func ContainsInSlice ¶
func GenerateCookies ¶
func GenerateCookies(res *Response)
func ParseCookies ¶
func ParseCookies(req *Request)
func String2Slice ¶
func Time2HttpDate ¶
func Time2HttpDate() string
Types ¶
type App ¶
type Config ¶
type Config struct { // Listening port, Default is 8080 Port int // The host address being monitored will be monitored by default, including IPv6 Host string // The log level is currently invalid, but it is currently under development LogLevel string // Multicore switch, which can increase speed for multicore devices Multicore bool // HTTP Proxy Mode ProxyMode bool }
type Connection ¶
type Cookie ¶
type Cookie struct { // Represents the value of the cookie. Value string // Represents the name of the cookie. Name string // Represents the path of the cookie. Path string // Represents the domain of the cookie. Domain string // A boolean value indicating whether the cookie can only be accessed via HTTP and cannot be accessed by client-side scripts (e.g., JavaScript). HttpOnly bool // A boolean value indicating whether the cookie can only be accessed via HTTPS and cannot be accessed by HTTP. Secure bool // A boolean value indicating whether the maximum age functionality is enabled for the cookie. If enabled, it is true; otherwise, it is false. MaxAgeEnable bool // contains filtered or unexported fields }
func (*Cookie) SetExpires ¶
type Request ¶
type Request struct { // URI of the request Uri *url.URL // Headers contains the headers Headers map[string][]string // Body contains the body of the request Body []byte // Path contains the parsed path of the request Path string // Method contains the HTTP method of the request Method string // Raw contains the raw bytes of the request Raw []byte // Version of the HTTP protocol used in the request Version string // Address of the remote peer of the request Addr string // Params contains the parsed parameters of the request Param map[string]string // Cookies contains the parsed cookies of the request Cookies map[string]*Cookie FormData map[string]*FormData }
func (*Request) AddToConnectionQueue ¶
type Response ¶
type Response struct { // HTTP response code Code string // Cookies contains the parsed cookies of the response Cookies map[string]*Cookie // Request is the *Request that generated this Response. // It can be used for getting request specific values. Req *Request // Chunked controls whether chunked transfer encoding should be applied. Chunked bool // Connection of the response. This is the gnet.Conn object of the connection from the client. Conn gnet.Conn // contains filtered or unexported fields }
func NewResponse ¶
func (*Response) GetHeaders ¶
func (*Response) PushBodyEnd ¶
func (res *Response) PushBodyEnd()
func (*Response) RemoveHeader ¶
func (*Response) SetContentType ¶
Click to show internal directories.
Click to hide internal directories.