Documentation ¶
Index ¶
- type Option
- type Router
- type RouterGroup
- type Server
- func (s *Server) Apply(cfg *conf.Configuration)
- func (s *Server) HandlerManager() *handler.Manager
- func (s *Server) ListenAndServe() (err error)
- func (s *Server) Router() *Router
- func (s *Server) Run() error
- func (s *Server) ServerOptions() ServerOptions
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop(ctx context.Context) error
- type ServerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(s *ServerOptions)
Option the function to apply configuration option
func RegisterMiddleware ¶ added in v0.0.3
func RegisterMiddleware(middleware handler.Middleware) Option
RegisterMiddleware inject a handler to server,then can be used in Server.Apply method
func RegisterMiddlewareByFunc ¶ added in v0.0.3
func RegisterMiddlewareByFunc(name string, handlerFunc handler.MiddlewareApplyFunc) Option
RegisterMiddlewareByFunc provide a simple way to inject a middleware by gin.HandlerFunc.
Notice: the middleware usual attach `c.Next()` or `c.Abort` to indicator whether exits the method. example:
RegisterMiddlewareByFunc("test",func(c *gin.Context) { ....process c.Next() or c.Abort() or c.AbortWithStatus(500) }
)
func WithConfiguration ¶ added in v0.1.0
func WithConfiguration(cfg *conf.Configuration) Option
WithConfiguration set up the configuration of the web server by a configuration instance
func WithGracefulStop ¶ added in v0.1.0
func WithGracefulStop() Option
WithGracefulStop indicate use graceful stop
type Router ¶
type Router struct { *gin.Engine Groups []*RouterGroup AfterRegisterInternalHandler func(*Router) // contains filtered or unexported fields }
Router is base on Gin you can use AfterRegisterInternalHandler to replace an inline HandlerFunc or add a new
func NewRouter ¶
func NewRouter(options *ServerOptions) *Router
func (*Router) FindGroup ¶ added in v0.0.3
func (r *Router) FindGroup(basePath string) *RouterGroup
FindGroup return a specified router group by an url format base path.
parameter basePath is map to configuration:
routerGroups: - group: basePath: "/auth"
type RouterGroup ¶ added in v0.0.3
type RouterGroup struct { Group *gin.RouterGroup Router *Router // contains filtered or unexported fields }
RouterGroup is a wrapper for gin.RouterGroup.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Apply ¶
func (s *Server) Apply(cfg *conf.Configuration)
func (*Server) HandlerManager ¶ added in v0.0.3
HandlerManager return server's handler manager,it's convenient to process handler
func (*Server) ListenAndServe ¶ added in v0.0.3
ListenAndServe Starts Http Server
return
http.ErrServerClosed or other error
func (*Server) ServerOptions ¶ added in v0.0.3
func (s *Server) ServerOptions() ServerOptions
ServerOptions return a setting used by web server