Documentation ¶
Index ¶
- Variables
- func AddMetaKvs(c *gin.Context, key, value string)
- func Download(c *gin.Context, mimeType MimeType, filename string, content []byte) error
- func Error(c *gin.Context, code int, msg string)
- func Failure(c *gin.Context, err error)
- func Forbidden(c *gin.Context, err error)
- func GetAuthorizationToken(c *gin.Context) (string, error)
- func GetMetaKvs(c *gin.Context) []string
- func GetRealIP(c *gin.Context) string
- func InvalidRequest(c *gin.Context, err error)
- func IsPrivateIp(ipStr string) bool
- func PermanentRedirect(c *gin.Context, location string)
- func Redirect(c *gin.Context, location string)
- func Success(c *gin.Context, args ...interface{})
- func SuccessPages(c *gin.Context, total int64, pages interface{})
- func SuccessRaw(c *gin.Context, result interface{})
- func Unauthorized(c *gin.Context, err error)
- type MimeType
- type PageResponse
- type Response
- type Route
- type RouterGroup
- type ServerOption
- type ServerParam
- type WebServer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenNotFound = errors.New("token not found") ErrInvalidHttpAuthorizationHeader = errors.New("invalid http authorization header") )
View Source
var (
ErrDuplicateRouterGroup = errors.New("duplicate router group")
)
View Source
var (
HttpContentTypes = map[MimeType]string{
MimeTypeBinary: "application/octet-stream",
MimeTypePDF: "application/pdf",
MimeTypeMSWord: "application/msword",
MimeTypeJPEG: "image/jpeg",
}
)
Functions ¶
func GetAuthorizationToken ¶
GetAuthorizationToken get bearer token or other token from http header
func InvalidRequest ¶
func PermanentRedirect ¶
func Success ¶
Success respond with data empty args respond with 'ok' message args[0] is the response data
func SuccessPages ¶
SuccessPages respond with pagination data
func SuccessRaw ¶
SuccessRaw respond with raw data
func Unauthorized ¶
Types ¶
type MimeType ¶
type MimeType int
const ( MimeTypeBinary MimeType MimeTypeJPEG MimeTypePDF MimeTypeMSWord )
type PageResponse ¶
type RouterGroup ¶
type RouterGroup struct { UrlPrefix string // contains filtered or unexported fields }
func (*RouterGroup) AddRoute ¶
func (rg *RouterGroup) AddRoute(routes ...*Route) error
func (*RouterGroup) Use ¶
func (rg *RouterGroup) Use(middlewares ...gin.HandlerFunc) *RouterGroup
type ServerOption ¶
type ServerOption func(param *ServerParam)
func WithGracefulShutdownWaitTime ¶
func WithGracefulShutdownWaitTime(waitTime time.Duration) ServerOption
type ServerParam ¶
type ServerParam struct {
// contains filtered or unexported fields
}
type WebServer ¶
type WebServer interface { Start() error Stop() error SetMode(mode string) GracefulStop(ctx context.Context) error AddRoutes(routes []*Route) error NewRouterGroup(urlPrefix string) *RouterGroup }
func NewHttpServer ¶
func NewHttpServer(logger intf.LoggerProvider, address string, options ...ServerOption) (WebServer, error)
func NewHttpsServer ¶
func NewHttpsServer(logger intf.LoggerProvider, address, certPath, keyPath string, options ...ServerOption) (WebServer, error)
Click to show internal directories.
Click to hide internal directories.