Documentation ¶
Index ¶
- Constants
- Variables
- func BodyLog() gin.HandlerFunc
- func CachePage(cache *cache.Cache) gin.HandlerFunc
- func Minify(m *minify.M, mediaType string) gin.HandlerFunc
- func NewMinifyResponseWriter(m *minify.M, w gin.ResponseWriter, r *http.Request) *minifyResponseWriter
- func PipeWriter(m *minify.M, mediatype string, w io.Writer) *minifyWriter
- type BodyWriter
- type CacheWriter
- type HTMLRender
- func (r *HTMLRender) Bytes(name string, data interface{}) ([]byte, error)
- func (r *HTMLRender) Configure(s *Server)
- func (r *HTMLRender) MustBytes(name string, data interface{}) []byte
- func (r *HTMLRender) MustString(name string, data interface{}) string
- func (r *HTMLRender) Output(w io.Writer, name string, data interface{}) error
- func (r *HTMLRender) String(name string, data interface{}) (string, error)
- type MinifyWriter
- type Response
- type Server
- type ServerConfigurator
Constants ¶
View Source
const ( // 正常 OK int = 0 // 参数错误 ParamsError int = 4001 // 数据错误 DataError int = 4002 )
Variables ¶
Functions ¶
func CachePage ¶
func CachePage(cache *cache.Cache) gin.HandlerFunc
CachePage sees if there are any cached responses and returns the cached response if one is available.
func Minify ¶
func Minify(m *minify.M, mediaType string) gin.HandlerFunc
func NewMinifyResponseWriter ¶
func NewMinifyResponseWriter(m *minify.M, w gin.ResponseWriter, r *http.Request) *minifyResponseWriter
**************************************************************************** NewMinifyResponseWriter 创建 NewMinifyResponseWriter
func PipeWriter ¶
Types ¶
type BodyWriter ¶
type BodyWriter struct {
// contains filtered or unexported fields
}
func NewBodyWriter ¶
func NewBodyWriter(cfg *config.Config) *BodyWriter
func (*BodyWriter) Configure ¶
func (b *BodyWriter) Configure(s *Server)
type CacheWriter ¶
type CacheWriter struct {
// contains filtered or unexported fields
}
func NewCacheWriter ¶
func NewCacheWriter(cfg *config.Config) *CacheWriter
func (*CacheWriter) Configure ¶
func (c *CacheWriter) Configure(s *Server)
type HTMLRender ¶
type HTMLRender struct {
// contains filtered or unexported fields
}
func NewHTMLRender ¶
func NewHTMLRender() *HTMLRender
func (*HTMLRender) Bytes ¶
func (r *HTMLRender) Bytes(name string, data interface{}) ([]byte, error)
func (*HTMLRender) Configure ¶
func (r *HTMLRender) Configure(s *Server)
func (*HTMLRender) MustBytes ¶
func (r *HTMLRender) MustBytes(name string, data interface{}) []byte
func (*HTMLRender) MustString ¶
func (r *HTMLRender) MustString(name string, data interface{}) string
type MinifyWriter ¶
type MinifyWriter struct {
// contains filtered or unexported fields
}
func NewMinifyWriter ¶
func NewMinifyWriter(cfg *config.Config) *MinifyWriter
func (*MinifyWriter) Configure ¶
func (c *MinifyWriter) Configure(s *Server)
type Response ¶
type Response struct { // 是否成功 Success bool `json:"success"` // 错误代码 ErrorCode int `json:"error_code"` // 消息 Message string `json:"message"` // 数据项 Data interface{} `json:"data"` }
Response Http响应
func NewResponse ¶
NewResponse 创建响应
func NewResponseError ¶
func NewResponseError(err interface{}, data ...interface{}) *Response
NewResponseError 创建错误响应, 显示原始错误
func NewResponseOK ¶
NewResponseOK 创建成功响应
type ServerConfigurator ¶
type ServerConfigurator interface {
Configure(*Server)
}
ServerConfigurator 服务器配置接口
func WithRenderTemplates ¶
func WithRenderTemplates(pattern string) ServerConfigurator
WithRenderTemplates 配置要呈现的模板路径
func WithTemplateFuncMap ¶
func WithTemplateFuncMap(funcMap template.FuncMap) ServerConfigurator
WithTemplateFuncMap 模板函数配置
Click to show internal directories.
Click to hide internal directories.