Documentation ¶
Index ¶
- Constants
- func Bytes2String(b []byte) string
- func HTTPResponse(success bool, message string, data interface{}, httpCode int, ...) error
- func NewPool() *sync.Pool
- func String2Bytes(s string) []byte
- type DB
- type Duration
- type HTTPd
- func (s *HTTPd) Close() error
- func (s *HTTPd) Open() error
- func (s *HTTPd) ReadBodyFail(w http.ResponseWriter, err error)
- func (s *HTTPd) Response(success bool, message string, data interface{}, httpCode int, ...)
- func (s *HTTPd) Serve()
- func (s *HTTPd) SetHandler(router *mux.Router)
- func (s *HTTPd) UnmarshalFail(w http.ResponseWriter, err error)
- func (s *HTTPd) ValidateFail(w http.ResponseWriter, err error)
- func (s *HTTPd) WithLogger(logger *zap.Logger)
- type HTTPdConfig
- type HttpResponse
- func (hr *HttpResponse) Free()
- func (hr *HttpResponse) GetData() interface{}
- func (hr *HttpResponse) GetMessage() string
- func (hr *HttpResponse) GetResponse() *response
- func (hr *HttpResponse) GetSuccess() bool
- func (hr *HttpResponse) SetData(d interface{})
- func (hr *HttpResponse) SetMessage(m string)
- func (hr *HttpResponse) SetSuccess(s bool)
Constants ¶
View Source
const ( DefaultAddr = ":1409" DefaultWriteTimeout = Duration(1000 * time.Millisecond) DefaultReadTimeout = Duration(1000 * time.Millisecond) DefaultReadHeaderTimeout = Duration(1000 * time.Millisecond) DefaultIdleTimeout = Duration(1000 * time.Millisecond) DefaultCloseTimeout = Duration(5 * time.Second) DefaultMonitorInterval = Duration(10 * time.Second) )
Variables ¶
This section is empty.
Functions ¶
func Bytes2String ¶
func HTTPResponse ¶ added in v0.0.3
func String2Bytes ¶
Types ¶
type DB ¶
type DB struct { *gorm.DB UserName string Password string IP string Port int DBName string Charset string Logger *zap.Logger }
type HTTPd ¶ added in v0.0.3
type HTTPd struct { Config HTTPdConfig Closing chan struct{} Closed chan struct{} Logger *zap.Logger Validator *validator.Validate // contains filtered or unexported fields }
func NewHTTPd ¶ added in v0.0.3
func NewHTTPd(config HTTPdConfig) (*HTTPd, error)
func (*HTTPd) ReadBodyFail ¶ added in v0.0.3
func (s *HTTPd) ReadBodyFail(w http.ResponseWriter, err error)
func (*HTTPd) SetHandler ¶ added in v0.0.3
func (*HTTPd) UnmarshalFail ¶ added in v0.0.3
func (s *HTTPd) UnmarshalFail(w http.ResponseWriter, err error)
func (*HTTPd) ValidateFail ¶ added in v0.0.3
func (s *HTTPd) ValidateFail(w http.ResponseWriter, err error)
func (*HTTPd) WithLogger ¶ added in v0.0.3
type HTTPdConfig ¶ added in v0.0.3
type HTTPdConfig struct { Addr string `yaml:"Addr,omitempty" mapstructure:"Addr,omitempty"` WriteTimeout Duration `yaml:"WriteTimeout,omitempty" mapstructure:"WriteTimeout,omitempty"` ReadTimeout Duration `yaml:"ReadTimeout,omitempty" mapstructure:"ReadTimeout,omitempty"` ReadHeaderTimeout Duration `yaml:"ReadHeaderTimeout,omitempty" mapstructure:"ReadHeaderTimeout,omitempty"` IdleTimeout Duration `yaml:"IdleTimeout,omitempty" mapstructure:"IdleTimeout,omitempty"` CloseTimeout Duration `yaml:"CloseTimeout,omitempty" mapstructure:"CloseTimeout,omitempty"` MonitorInterval Duration `yaml:"MonitorInterval,omitempty" mapstructure:"MonitorInterval,omitempty"` }
func NewHTTPdConfig ¶ added in v0.0.3
func NewHTTPdConfig() HTTPdConfig
type HttpResponse ¶ added in v0.0.3
type HttpResponse struct {
// contains filtered or unexported fields
}
func GetResponseWrapper ¶ added in v0.0.3
func GetResponseWrapper() *HttpResponse
func GetResponseWrapperFromBytes ¶ added in v0.0.3
func GetResponseWrapperFromBytes(bs []byte) (*HttpResponse, error)
func GetResponseWrapperFromString ¶ added in v0.0.3
func GetResponseWrapperFromString(s string) (*HttpResponse, error)
func (*HttpResponse) Free ¶ added in v0.0.3
func (hr *HttpResponse) Free()
func (*HttpResponse) GetData ¶ added in v0.0.3
func (hr *HttpResponse) GetData() interface{}
func (*HttpResponse) GetMessage ¶ added in v0.0.3
func (hr *HttpResponse) GetMessage() string
func (*HttpResponse) GetResponse ¶ added in v0.0.3
func (hr *HttpResponse) GetResponse() *response
func (*HttpResponse) GetSuccess ¶ added in v0.0.3
func (hr *HttpResponse) GetSuccess() bool
func (*HttpResponse) SetData ¶ added in v0.0.3
func (hr *HttpResponse) SetData(d interface{})
func (*HttpResponse) SetMessage ¶ added in v0.0.3
func (hr *HttpResponse) SetMessage(m string)
func (*HttpResponse) SetSuccess ¶ added in v0.0.3
func (hr *HttpResponse) SetSuccess(s bool)
Click to show internal directories.
Click to hide internal directories.