Documentation ¶
Index ¶
- Constants
- func IsFormData(contentType string) bool
- func IsJSON(contentType string) bool
- func IsUrlEncode(contentType string) bool
- type BeeFile
- type BeeRequest
- func (req *BeeRequest) AddParam(name string, val string)
- func (req *BeeRequest) ContentType() string
- func (req *BeeRequest) FormValue(key string) string
- func (req *BeeRequest) FormValues(key string) []string
- func (req *BeeRequest) GetFile(key string) (*BeeFile, error)
- func (req *BeeRequest) HeaderValue(key string) string
- func (req *BeeRequest) HeaderValues(key string) []string
- type BeeResponse
- func (res *BeeResponse) SendData(value string)
- func (res *BeeResponse) SendErrorMsg(code int, msg string)
- func (res *BeeResponse) SendHtml(value string)
- func (res *BeeResponse) SendJson(value string)
- func (res *BeeResponse) SendStream(fileName string, file []byte)
- func (res *BeeResponse) SendText(value string)
- func (res *BeeResponse) SetHeader(key string, value string) *BeeResponse
- type BeeSession
Constants ¶
const ( UrlEncode = "application/x-www-form-urlencoded" FormData = "multipart/form-data" JSON = "application/json" ContentType = "Content-Type" ContentType2 = "content-type" ContentDisposition = "Content-Disposition" ErrorMsg = "{\"code\":%s, \"msg\":\"%s\"}" CarriageReturn = "\r\n" )
const ( Connection = "Connection" Upgrade = "Upgrade" SecWebsocketKey = "Sec-WebSocket-Key" SecWebsocketProtocol = "Sec-WebSocket-Protocol" ResponseOnline = "HTTP/1.1 101 Switching Protocols" // SocketSecretKey SecretKey encryption secret key SocketSecretKey = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" )
Variables ¶
This section is empty.
Functions ¶
func IsFormData ¶
func IsUrlEncode ¶
Types ¶
type BeeRequest ¶
type BeeRequest struct { Request *http.Request Json string RoutePath string Params map[string][]string }
BeeRequest ----------- Secondary wrapping over the request object, mainly to facilitate the acquisition of json passing parameters ----------- Secondary encapsulation of a part of the high-frequency use of the function, other functions can be taken from the Request inside
func (*BeeRequest) AddParam ¶
func (req *BeeRequest) AddParam(name string, val string)
AddParam add param
func (*BeeRequest) ContentType ¶
func (req *BeeRequest) ContentType() string
ContentType get Content-Type
func (*BeeRequest) FormValue ¶
func (req *BeeRequest) FormValue(key string) string
FormValue Get request parameters
func (*BeeRequest) FormValues ¶
func (req *BeeRequest) FormValues(key string) []string
FormValues Get request parameters
func (*BeeRequest) GetFile ¶
func (req *BeeRequest) GetFile(key string) (*BeeFile, error)
GetFile Get request file
func (*BeeRequest) HeaderValue ¶
func (req *BeeRequest) HeaderValue(key string) string
HeaderValue Get request header
func (*BeeRequest) HeaderValues ¶
func (req *BeeRequest) HeaderValues(key string) []string
HeaderValues Get request headers
type BeeResponse ¶
type BeeResponse struct {
Response http.ResponseWriter
}
BeeResponse ----------- Secondary wrapping of the response object, the response part is enhanced a bit, providing some high-frequency use of the function -----------
func (*BeeResponse) SendData ¶
func (res *BeeResponse) SendData(value string)
SendData Sending other custom ContentType data to the client
func (*BeeResponse) SendErrorMsg ¶
func (res *BeeResponse) SendErrorMsg(code int, msg string)
SendErrorMsg Return error messages in json format
func (*BeeResponse) SendHtml ¶
func (res *BeeResponse) SendHtml(value string)
SendHtml Send html string to client
func (*BeeResponse) SendJson ¶
func (res *BeeResponse) SendJson(value string)
SendJson Send json string to client
func (*BeeResponse) SendStream ¶
func (res *BeeResponse) SendStream(fileName string, file []byte)
SendStream Send file to client
func (*BeeResponse) SendText ¶
func (res *BeeResponse) SendText(value string)
SendText Send text to client
func (*BeeResponse) SetHeader ¶
func (res *BeeResponse) SetHeader(key string, value string) *BeeResponse
SetHeader Set the response header
type BeeSession ¶
BeeSession Session Management, Based on the aes algorithm The basic principle of creating a token is to convert the data into a json string, then splice a timeout to the end, then perform aes encryption, and then convert the encrypted cipher text to base64 output To restore the token, reverse the creation process, first convert the base64 string to cipher text, then decrypt the cipher text with aes, after decryption, get a string with a timeout at the end, split the string into json and timeout, and determine whether the timeout is over, if not, convert the json string to the specified type of data.
func (BeeSession) CreateToken ¶
func (bs BeeSession) CreateToken(data interface{}) (string, error)
CreateToken Create a token based on the parameters passed in Parameters must be of type struct
func (BeeSession) RestoreToken ¶
func (bs BeeSession) RestoreToken(token string, dst interface{}) error
RestoreToken Restore the token to the original data The second parameter must be a pointer of type struct