Documentation ¶
Index ¶
- Constants
- func CORSDefault() echo.MiddlewareFunc
- func Get(ctx context.Context) (httpsrv.Provider, error)
- func GetEnity(ctx context.Context, enityName string) (interface{}, error)
- func Handler(f HandlerFunc) echo.HandlerFunc
- func HandlerLogger(parent *zerolog.Logger, ec echo.Context) (log zerolog.Logger, requestID string, err error)
- func HydrationLogger(log *zerolog.Logger) echo.MiddlewareFunc
- func HydrationRequestID() echo.MiddlewareFunc
- func Registrate(ctx context.Context) (context.Context, error)
- func RegistrateEnity(ctx context.Context, enityName string, options interface{}) (context.Context, error)
- type Config
- type Context
- func (ec Context) AddToSwagger() swagger.IMethod
- func (ec Context) BadRequest(err error) error
- func (ec Context) CreateFailed(err error) error
- func (ec Context) Forbidden(err error) error
- func (ec Context) GetInt64Param(param string) (int64, error)
- func (ec Context) GetLog() *zerolog.Logger
- func (ec Context) GetReqID() string
- func (ec Context) HasExpired(err error) error
- func (ec Context) InternalServerError(err error) error
- func (ec Context) IsBuildingSwagger() bool
- func (ec Context) NotDeleted(err error) error
- func (ec Context) NotFound(err error) error
- func (ec Context) NotUpdated(err error) error
- func (ec Context) OK(data interface{}) error
- func (ec Context) OkResult() error
- func (ec Context) Unauthorized(err error) error
- type Enity
- func (srv *Enity) BuildSwagger()
- func (srv *Enity) CreateAPIVersionGroup(apiVersion string, middlewares ...interface{}) error
- func (srv *Enity) GetAPIVersionGroup(apiVersion string) (*Group, error)
- func (srv *Enity) IsStarted() bool
- func (srv *Enity) RegisterEndpoint(method, endpoint string, handler http.Handler, m ...httpsrv.MiddleWareFunc) error
- func (srv *Enity) Shutdown() error
- func (srv *Enity) Start() error
- type Group
- type HandlerFunc
- type Provider
- func (p *Provider) CreateAPIVersionGroup(serverName, apiVersion string, middlewares ...interface{}) error
- func (p *Provider) CreateEnity(enityName string, options interface{}) error
- func (p *Provider) GetAPIVersionGroup(serverName, apiVersion string) (interface{}, error)
- func (p *Provider) GetEnity(connectionName string) (interface{}, error)
- func (p *Provider) RegisterEndpoint(serverName, method, endpoint string, handler http.Handler, ...) error
Constants ¶
const DefaultProviderName = "echo"
Variables ¶
This section is empty.
Functions ¶
func CORSDefault ¶
func CORSDefault() echo.MiddlewareFunc
CORSDefault allows requests from any origin wth GET, HEAD, PUT, POST or DELETE method.
func Handler ¶
func Handler(f HandlerFunc) echo.HandlerFunc
func HandlerLogger ¶
func HandlerLogger(parent *zerolog.Logger, ec echo.Context) (log zerolog.Logger, requestID string, err error)
HandlerLogger handler that adds requesID into logger fields
func HydrationLogger ¶ added in v0.2.0
func HydrationRequestID ¶
func HydrationRequestID() echo.MiddlewareFunc
Types ¶
type Config ¶
type Config struct { // Address is an address on which HTTP server will listen. Address string `envconfig:"optional"` // DisableHTTP2 disabled HTTP2 features (only HTTP 1.0/1.1 will work). DisableHTTP2 bool `envconfig:"optional"` // Debug enables internal echo debugging features. Debug bool `envconfig:"optional"` // HideBanner disables showing Echo banner on server's start. HideBanner bool `envconfig:"optional"` // HidePort disables showing address and port on which Echo will listen // for connections. HidePort bool `envconfig:"optional"` // Path to certificate for HTTPS CertFile string `envconfig:"optional"` // Path to key for HTTPS KeyFile string `envconfig:"optional"` // Timeouts // BodyReadTimeout sets body reading timeout in seconds. Defaults // to 10 seconds. BodyReadTimeout time.Duration `envconfig:"optional"` // BodyWriteTimeout sets body writing timeout in seconds. Defaults // to 10 seconds. BodyWriteTimeout time.Duration `envconfig:"optional"` // HeaderReadTimeout sets headers reading timeout in seconds. Defaults // to 5 seconds. HeaderReadTimeout time.Duration `envconfig:"optional"` // Middlewares for server endpoints Middlewares []interface{} `envconfig:"-"` }
func (*Config) InitilizeEcho ¶
func (sc *Config) InitilizeEcho(e *echo.Echo)
type Context ¶
type Context struct {
echo.Context
}
func (Context) AddToSwagger ¶ added in v0.4.0
func (Context) BadRequest ¶ added in v0.4.0
BadRequest return err 400
func (Context) CreateFailed ¶ added in v0.4.0
CreateFailed return err 409
func (Context) GetInt64Param ¶ added in v0.4.0
func (Context) HasExpired ¶ added in v0.4.0
HasExpired return err 408
func (Context) InternalServerError ¶ added in v0.4.0
InternalServerError return err 500
func (Context) IsBuildingSwagger ¶ added in v0.4.0
func (Context) NotDeleted ¶ added in v0.4.0
NotDeleted return err 406
func (Context) NotUpdated ¶ added in v0.4.0
NotUpdated return err 409
func (Context) Unauthorized ¶ added in v0.4.0
Unauthorized return err 401
type Enity ¶
type Enity struct { // Server is an echo.Echo thing that represents HTTP server. Server *echo.Echo // contains filtered or unexported fields }
Enity describes every HTTP server's structure and configuration.
func GetEnityTypeCast ¶
func (*Enity) BuildSwagger ¶
func (srv *Enity) BuildSwagger()
BuildSwagger build/rebuild swagger for all apiGroups
func (*Enity) CreateAPIVersionGroup ¶
CreateAPIVersionGroup creates routing group for desired API version. If API group was already created it will return nil and error about that.
func (*Enity) GetAPIVersionGroup ¶
GetAPIVersionGroup will return created API version routing group. It will return nil and error if API group wasn't created.
func (*Enity) RegisterEndpoint ¶
type Group ¶
type Group struct {
echo.Group
}
func GetAPIVersionGroup ¶ added in v0.2.0
func (*Group) ToEchoGroup ¶
func (gr *Group) ToEchoGroup() *echo.Group
type HandlerFunc ¶
type Provider ¶
Provider is a HTTP server provider using labstack's Echo HTTP framework.
func NewProvider ¶
Initialize should initialize provider. If asynchronous mode supported by provider (e.g. for batch inserting using transactions) queue processor should also be started here.
func (*Provider) CreateAPIVersionGroup ¶
func (p *Provider) CreateAPIVersionGroup(serverName, apiVersion string, middlewares ...interface{}, ) error
CreateAPIVersionGroup creates requested API version routes group. Passed apiVersion should be a string with API version without leading "v", "version" or anything like that.
func (*Provider) CreateEnity ¶
CreateEnity should create enity using passed parameters.
func (*Provider) GetAPIVersionGroup ¶
GetAPIVersionGroup returns routes grouping for passed apiVersion. Passed apiVersion should be a string with API version without leading "v", "version" or anything like that.
func (*Provider) RegisterEndpoint ¶
func (p *Provider) RegisterEndpoint( serverName, method, endpoint string, handler http.Handler, middleware ...httpsrv.MiddleWareFunc) error
RegisterEndpoint register endpoint on HTTP server.