Documentation
¶
Index ¶
- Constants
- func DecorateHandlerFunc(handlerFunc iris.HandlerFunc, mws ...Middleware) []iris.HandlerFunc
- func GetMiddlewareHandlerFunc(mws ...Middleware) []iris.HandlerFunc
- func NewStLogFunc(logger log.StLogger) iris.HandlerFunc
- func NewStandardLogFunc(logger log.StandardLogger) iris.HandlerFunc
- func NewStructuredLogFunc(logger log.StructuredLogger) iris.HandlerFunc
- type AddRoutesFunc
- type AlaudaError
- type Config
- type DiagnoseRouter
- type Handler
- type Middleware
- type Router
- type Server
- func (h *Server) AddEndpoint(relativePath string, handler Router) *Server
- func (h *Server) AddMiddleware(mw Middleware, kinds ...string) *Server
- func (h *Server) AddMiddlewares(mws []Middleware, kinds ...string) *Server
- func (h *Server) AddVersion(version int) *Server
- func (h *Server) AddVersionEndpoint(version int, relativePath string, handler Router) *Server
- func (h *Server) AddVersionEndpointFunc(version int, relativePath string, addRoutesFunc AddRoutesFunc) *Server
- func (h *Server) AuthHealthcheck(ctx *iris.Context)
- func (h *Server) GetApp() *iris.Framework
- func (h *Server) GetMiddlewareHandlerFun(kind string) []iris.HandlerFunc
- func (h *Server) GetMiddlewares(kind string) []Middleware
- func (h *Server) GetMiddlewaresDecorated(handlerFunc iris.HandlerFunc, kinds ...string) []iris.HandlerFunc
- func (h *Server) Healthcheck(ctx *iris.Context)
- func (h *Server) Init() *Server
- func (h *Server) Start()
Constants ¶
const (
// MiddlewareTypeAll special type
MiddlewareTypeAll = "*"
)
const (
// USER constant key for user in iris.Context
USER = "USER"
)
Variables ¶
This section is empty.
Functions ¶
func DecorateHandlerFunc ¶
func DecorateHandlerFunc(handlerFunc iris.HandlerFunc, mws ...Middleware) []iris.HandlerFunc
DecorateHandlerFunc prepend all the given middlewares
func GetMiddlewareHandlerFunc ¶
func GetMiddlewareHandlerFunc(mws ...Middleware) []iris.HandlerFunc
GetMiddlewareHandlerFunc get only the functions from middlewares
func NewStLogFunc ¶
func NewStLogFunc(logger log.StLogger) iris.HandlerFunc
NewStLogFunc returns a middleware print function using StLogger
func NewStandardLogFunc ¶
func NewStandardLogFunc(logger log.StandardLogger) iris.HandlerFunc
NewStandardLogFunc returns a middleware print function using StandardLogger
func NewStructuredLogFunc ¶
func NewStructuredLogFunc(logger log.StructuredLogger) iris.HandlerFunc
NewStructuredLogFunc returns a middleware print function using StructuredLogger
Types ¶
type AddRoutesFunc ¶
AddRoutesFunc a function to add a route
type AlaudaError ¶
type AlaudaError struct {
Errors []error `json:"errors"`
}
AlaudaError structure to represent alauda's standard error format
func NewAlaudaError ¶
func NewAlaudaError(err ...error) *AlaudaError
NewAlaudaError constructor function for the errors
type Config ¶
type Config struct {
Host string
Port string
AddLog bool
LogFunc iris.HandlerFunc
AddHealthCheck bool
TreatNotFoundError bool
NotFoundFunc iris.HandlerFunc
Component string
MaxReadBufferSize int
AllowedOrigins []string
}
Config configuration for the HTTP server
func (Config) GetCorsOptions ¶
GetCorsOptions return cors options for iris http router
func (Config) GetIrisOptions ¶
func (c Config) GetIrisOptions() []iris.OptionSetter
GetIrisOptions returns the options for the iris http server
func (Config) SaneDefaults ¶
SaneDefaults verifies the options and sets some sane defaults if the set values are not setup or not valid
type DiagnoseRouter ¶
type DiagnoseRouter struct {
*diagnose.HealthChecker
}
DiagnoseRouter struct to add a route
func NewDiagnoser ¶
func NewDiagnoser(checker *diagnose.HealthChecker) *DiagnoseRouter
NewDiagnoser constructor for a diagnose checker
type Handler ¶
type Handler struct {
}
Handler base handler with common shared methods can be composed to provide default behaviour
func (Handler) GetContext ¶
GetContext get context with predefined keys
func (Handler) HandleError ¶
HandleError Function to handle errors and return a message
type Middleware ¶
Middleware adding middleware
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server Full HTTP server
func (*Server) AddEndpoint ¶
AddEndpoint ands a handler for the given relative path should be executed before the Start method and after the Init method
func (*Server) AddMiddleware ¶
func (h *Server) AddMiddleware(mw Middleware, kinds ...string) *Server
AddMiddleware adds a middleware for the given types
func (*Server) AddMiddlewares ¶
func (h *Server) AddMiddlewares(mws []Middleware, kinds ...string) *Server
AddMiddlewares adds a middleware for the given types
func (*Server) AddVersion ¶
AddVersion Adds a version number to the API route
func (*Server) AddVersionEndpoint ¶
AddVersionEndpoint add a root endpoint to a version specific API Used like AddEndpoint but will add on a specific version instead. If the version was not created previously will then be created automatically
func (*Server) AddVersionEndpointFunc ¶
func (h *Server) AddVersionEndpointFunc(version int, relativePath string, addRoutesFunc AddRoutesFunc) *Server
AddVersionEndpointFunc add a root endpoint to a version specific API Used like AddEndpoint but will add on a specific version instead. If the version was not created previously will then be created automatically
func (*Server) AuthHealthcheck ¶
AuthHealthcheck healthcheck endpoint
func (*Server) GetMiddlewareHandlerFun ¶
func (h *Server) GetMiddlewareHandlerFun(kind string) []iris.HandlerFunc
GetMiddlewareHandlerFun returns all the handler functions of a middleware kind
func (*Server) GetMiddlewares ¶
func (h *Server) GetMiddlewares(kind string) []Middleware
GetMiddlewares get all midlewares of a kind
func (*Server) GetMiddlewaresDecorated ¶
func (h *Server) GetMiddlewaresDecorated(handlerFunc iris.HandlerFunc, kinds ...string) []iris.HandlerFunc
GetMiddlewaresDecorated gets all the handler functions of a collection of kinds and decorate the target function
func (*Server) Healthcheck ¶
Healthcheck healthcheck endpoint