Documentation ¶
Index ¶
- Constants
- Variables
- func AssetHandler(prefix, root, indexFile string, assets embed.FS) http.Handler
- func Do(req *http.Request, resp func(*http.Response) error) (err error)
- func FileServer(port, prefix, root, indexFile string, assets embed.FS) error
- func Get(url string, resp func(*http.Response) error) (err error)
- func JsonUnmarshalResponse(resp interface{}, body []byte) error
- func MainDomain(domain string) string
- func Publicsuffix(domain string) string
- type Request
- type Resp
- type Response
- func (r *Response) JSON(body interface{}) error
- func (r *Response) JSONP(callbackFunc string, body interface{}) error
- func (r *Response) JSONResp(body *Resp) error
- func (r *Response) JSONRespWithStatus(statusCode int, body *Resp) error
- func (r *Response) JSONWithStatus(statusCode int, body interface{}) error
Constants ¶
View Source
const ( // ConContent-Type ConContentType string = "ConContent-Type" ConContentTypeJson string = "application/json; charset=utf-8" ConContentTypeJavaScript string = "application/x-javascript;charset=UTF-8" // Connection Connection string = "Connection" ConnectionKeepAlive string = "keep-alive" // Accept-Language AcceptLanguage string = "Accept-Language" AcceptLanguageZhCN string = "zh-CN,zh;q=0.9" // Accept-Encoding AcceptEncoding string = "Accept-Language" AcceptEncodingGzip string = "gzip" AcceptEncodingDeflate string = "deflate" AcceptEncodingBr string = "br" AcceptEncodingDefault string = "gzip, deflate, br" // User-Agent UserAgent string = "User-Agent" UserAgentWindowsChrome93_0_4577_63 string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36" UserAgentWindowsFirefox92_0 string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0" )
Variables ¶
View Source
var DefaultClient = &http.Client{}
Functions ¶
func AssetHandler ¶
AssetHandler 返回一个 http.Handler ,它将从 资产嵌入.FS。定位文件时,它将删除给定的 请求中的前缀并将根添加到文件系统中 查找:典型的前缀可能是 /web/,而 root 将被构建。
func FileServer ¶
FileServer web server
func JsonUnmarshalResponse ¶
func MainDomain ¶
func Publicsuffix ¶
Types ¶
type Request ¶
func NewRequest ¶
func (*Request) GetQueryInt ¶
func (*Request) GetQueryInt_ ¶
func (*Request) GetQueryString ¶
func (*Request) GetQueryString_ ¶
type Response ¶
type Response struct {
http.ResponseWriter
}
func NewResponse ¶
func NewResponse(w http.ResponseWriter) *Response
func (*Response) JSONRespWithStatus ¶
func (*Response) JSONWithStatus ¶
Click to show internal directories.
Click to hide internal directories.