Documentation ¶
Overview ¶
Package app eagle defines something for app
Index ¶
- Variables
- func Error(c *gin.Context, err error)
- func HealthCheck(c *gin.Context)
- func RouteNotFound(c *gin.Context)
- func Sign(ctx context.Context, payload map[string]interface{}, secret string, ...) (tokenString string, err error)
- func Success(c *gin.Context, data interface{})
- type App
- type Config
- type Option
- func WithContext(ctx context.Context) Option
- func WithEndpoint(endpoints ...*url.URL) Option
- func WithID(id string) Option
- func WithLogger(logger log.Logger) Option
- func WithMetadata(md map[string]string) Option
- func WithName(name string) Option
- func WithRegistry(r registry.Registry) Option
- func WithServer(srv ...transport.Server) Option
- func WithSignal(sigs ...os.Signal) Option
- func WithVersion(version string) Option
- type Payload
- type Response
- type ServerConfig
- type ValidError
- type ValidErrors
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingHeader means the `Authorization` header was empty. ErrMissingHeader = errors.New("the length of the `Authorization` header is zero") )
Functions ¶
func HealthCheck ¶
HealthCheck will return OK if the underlying BoltDB is healthy. At least healthy enough for demoing purposes.
func Sign ¶
func Sign(ctx context.Context, payload map[string]interface{}, secret string, timeout int64) (tokenString string, err error)
Sign signs the payload with the specified secret. The token content. iss: (Issuer)签发者 iat: (Issued At)签发时间,用Unix时间戳表示 exp: (Expiration Time)过期时间,用Unix时间戳表示 aud: (Audience)接收该JWT的一方 sub: (Subject)该JWT的主题 nbf: (Not Before)不要早于这个时间 jti: (JWT ID)用于标识JWT的唯一ID
Types ¶
type Config ¶
type Config struct { Name string Version string Mode string PprofPort string URL string JwtSecret string JwtTimeout int SSL bool CtxDefaultTimeout time.Duration CSRF bool Debug bool EnableTrace bool EnablePprof bool HTTP ServerConfig GRPC ServerConfig }
Config global config nolint
var ( // Conf global app var Conf *Config )
type Option ¶
type Option func(o *options)
Option is func for application
func WithEndpoint ¶
WithEndpoint with service endpoint.
func WithMetadata ¶
WithMetadata with service metadata.
func WithRegistry ¶
WithRegistry with service registry.
func WithServer ¶
WithServer with a server , http or grpc
type Payload ¶
type Payload struct {
UserID uint64
}
Payload is the data of the JSON web token.
type Response ¶
type Response struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` Details []string `json:"details,omitempty"` }
Response define a response struct
type ServerConfig ¶
type ServerConfig struct { Network string Addr string ReadTimeout time.Duration WriteTimeout time.Duration }
ServerConfig server config.
type ValidError ¶
ValidError .
type ValidErrors ¶
type ValidErrors []*ValidError
ValidErrors .
func BindAndValid ¶
func BindAndValid(c *gin.Context, v interface{}) (bool, ValidErrors)
BindAndValid valid params