fix log
This commit is contained in:
parent
908931bc01
commit
c027ef22bc
11
app.go
11
app.go
|
@ -6,6 +6,7 @@ import (
|
|||
"os/signal"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
|
@ -35,12 +36,19 @@ func (s *Service) Name() string {
|
|||
}
|
||||
|
||||
func (s *Service) Debug() bool {
|
||||
if s.opts != nil {
|
||||
return s.opts.debug
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Service) Version() string {
|
||||
return s.opts.version
|
||||
if s.opts != nil {
|
||||
return s.opts.version
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *Service) Metadata() map[string]string {
|
||||
if s.service == nil {
|
||||
return nil
|
||||
|
@ -255,6 +263,7 @@ func New(cbs ...Option) *Service {
|
|||
registrarTimeout: time.Second * 30,
|
||||
},
|
||||
}
|
||||
s.opts.debug, _ = strconv.ParseBool("AEUS_DEBUG")
|
||||
s.opts.metadata = make(map[string]string)
|
||||
for _, cb := range cbs {
|
||||
cb(s.opts)
|
||||
|
|
|
@ -108,9 +108,7 @@ func JWT(keyFunc jwt.Keyfunc, cbs ...Option) middleware.Middleware {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(token, bearerWord) {
|
||||
token = strings.TrimPrefix(token, bearerWord)
|
||||
}
|
||||
token, _ = strings.CutPrefix(token, bearerWord)
|
||||
var (
|
||||
ti *jwt.Token
|
||||
)
|
||||
|
|
12
options.go
12
options.go
|
@ -2,6 +2,7 @@ package aeus
|
|||
|
||||
import (
|
||||
"context"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"git.nobla.cn/golang/aeus/pkg/logger"
|
||||
|
@ -18,6 +19,7 @@ type options struct {
|
|||
servers []Server
|
||||
endpoints []string
|
||||
scope Scope
|
||||
debug bool
|
||||
registrarTimeout time.Duration
|
||||
registry registry.Registry
|
||||
serviceLoader ServiceLoader
|
||||
|
@ -41,9 +43,7 @@ func WithMetadata(metadata map[string]string) Option {
|
|||
if o.metadata == nil {
|
||||
o.metadata = make(map[string]string)
|
||||
}
|
||||
for k, v := range metadata {
|
||||
o.metadata[k] = v
|
||||
}
|
||||
maps.Copy(o.metadata, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,12 @@ func WithScope(scope Scope) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithDebug(debug bool) Option {
|
||||
return func(o *options) {
|
||||
o.debug = debug
|
||||
}
|
||||
}
|
||||
|
||||
func WithServiceLoader(loader ServiceLoader) Option {
|
||||
return func(o *options) {
|
||||
o.serviceLoader = loader
|
||||
|
|
|
@ -22,6 +22,10 @@ func (c *Context) Context() context.Context {
|
|||
return c.ctx.Request.Context()
|
||||
}
|
||||
|
||||
func (c *Context) Gin() *gin.Context {
|
||||
return c.ctx
|
||||
}
|
||||
|
||||
func (c *Context) Request() *http.Request {
|
||||
return c.ctx.Request
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue