Documentation ¶
Index ¶
- Constants
- Variables
- func Initialize(e *echo.Echo, api APIInterface, apiConfig string) *echo.Echo
- func LoadHttpRequestFixture(filename string) (*http.Request, error)
- func LoadHttpResponseFixture(filename string, req *http.Request) (*http.Response, error)
- func MultiWriter(writers ...http.ResponseWriter) http.ResponseWriter
- func NewControllerError(message string, err error, code int) *echo.HTTPError
- func NewLogger(l echo.Logger) log.Ext1FieldLogger
- func NewRespBodyFromBytes(body []byte) io.ReadCloser
- func Static(root string) echo.MiddlewareFunc
- func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc
- type API
- func (p *API) AccountID(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) AddConfig(config *APIConfig) error
- func (p *API) AddPathConfig(path string, config *PathConfig) error
- func (a *API) Authenticate(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func (p *API) Context(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) EchoInstance() *echo.Echo
- func (p *API) HTTPSRedirect(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func (p *API) HealthChecker(c echo.Context) error
- func (p *API) Initialize() error
- func (p *API) LogLevel(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) Logger(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func (p *API) Recover(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func (p *API) RequestID(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) RequestRecording(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) ResponseRecording(next echo.HandlerFunc) echo.HandlerFunc
- func (p *API) SetEchoInstance(e *echo.Echo)
- func (p *API) Static(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func (p *API) UserID(next echo.HandlerFunc) echo.HandlerFunc
- type APIConfig
- type APIInterface
- type Context
- type JWTConfig
- type LoggerWrapper
- func (l LoggerWrapper) Debug(args ...interface{})
- func (l LoggerWrapper) Debugf(format string, args ...interface{})
- func (l LoggerWrapper) Debugln(args ...interface{})
- func (l LoggerWrapper) Error(args ...interface{})
- func (l LoggerWrapper) Errorf(format string, args ...interface{})
- func (l LoggerWrapper) Errorln(args ...interface{})
- func (l LoggerWrapper) Fatal(args ...interface{})
- func (l LoggerWrapper) Fatalf(format string, args ...interface{})
- func (l LoggerWrapper) Fatalln(args ...interface{})
- func (l LoggerWrapper) Info(args ...interface{})
- func (l LoggerWrapper) Infof(format string, args ...interface{})
- func (l LoggerWrapper) Infoln(args ...interface{})
- func (l LoggerWrapper) Panic(args ...interface{})
- func (l LoggerWrapper) Panicf(format string, args ...interface{})
- func (l LoggerWrapper) Panicln(args ...interface{})
- func (l LoggerWrapper) Print(args ...interface{})
- func (l LoggerWrapper) Printf(format string, args ...interface{})
- func (l LoggerWrapper) Println(args ...interface{})
- func (l LoggerWrapper) Trace(args ...interface{})
- func (l LoggerWrapper) Tracef(format string, args ...interface{})
- func (l LoggerWrapper) Traceln(args ...interface{})
- func (l LoggerWrapper) Warn(args ...interface{})
- func (l LoggerWrapper) Warnf(format string, args ...interface{})
- func (l LoggerWrapper) Warning(args ...interface{})
- func (l LoggerWrapper) Warningf(format string, args ...interface{})
- func (l LoggerWrapper) Warningln(args ...interface{})
- func (l LoggerWrapper) Warnln(args ...interface{})
- func (l LoggerWrapper) WithError(err error) *log.Entry
- func (l LoggerWrapper) WithField(key string, value interface{}) *log.Entry
- func (l LoggerWrapper) WithFields(fields log.Fields) *log.Entry
- type PathConfig
- type StaticConfig
Constants ¶
const HeaderXAccountID = "X-Account-ID"
Handlers container for all handlers
Variables ¶
var ( // DefaultStaticConfig is the default Static middleware config. DefaultStaticConfig = StaticConfig{ Skipper: middleware.DefaultSkipper, Index: "index.html", } )
Functions ¶
func Initialize ¶
func Initialize(e *echo.Echo, api APIInterface, apiConfig string) *echo.Echo
func LoadHttpRequestFixture ¶
LoadHttpRequestFixture wrapper around the test helper to make it easier to use it with test table
func LoadHttpResponseFixture ¶
LoadHttpResponseFixture wrapper around the test helper to make it easier to use it with test table
func MultiWriter ¶
func MultiWriter(writers ...http.ResponseWriter) http.ResponseWriter
MultiWriter creates a writer that duplicates its writes to all the provided writers, similar to the Unix tee(1) command.
Each write is written to each listed writer, one at a time. If a listed writer returns an error, that overall write operation stops and returns the error; it does not continue down the list.
func NewControllerError ¶
func NewLogger ¶
func NewLogger(l echo.Logger) log.Ext1FieldLogger
func NewRespBodyFromBytes ¶
func NewRespBodyFromBytes(body []byte) io.ReadCloser
NewRespBodyFromBytes creates an io.ReadCloser from a byte slice that is suitable for use as an http response body.
func Static ¶
func Static(root string) echo.MiddlewareFunc
Static returns a Static middleware to serves static content from the provided root directory.
func StaticWithConfig ¶
func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc
StaticWithConfig returns a Static middleware with config. See `Static()`.
Types ¶
type API ¶
type API struct { Config *APIConfig PathConfigs map[string]*PathConfig // contains filtered or unexported fields }
func (*API) AddPathConfig ¶
func (p *API) AddPathConfig(path string, config *PathConfig) error
func (*API) Authenticate ¶
func (a *API) Authenticate(handlerFunc echo.HandlerFunc) echo.HandlerFunc
Functionality to check claims will be added here
func (*API) EchoInstance ¶
func (p *API) EchoInstance() *echo.Echo
func (*API) HTTPSRedirect ¶
func (p *API) HTTPSRedirect(handlerFunc echo.HandlerFunc) echo.HandlerFunc
func (*API) HealthChecker ¶
func (*API) Initialize ¶
func (*API) RequestRecording ¶
func (p *API) RequestRecording(next echo.HandlerFunc) echo.HandlerFunc
func (*API) ResponseRecording ¶
func (p *API) ResponseRecording(next echo.HandlerFunc) echo.HandlerFunc
func (*API) SetEchoInstance ¶
func (p *API) SetEchoInstance(e *echo.Echo)
type APIConfig ¶
type APIConfig struct { *weos.ApplicationConfig BasePath string `json:"basePath" ,yaml:"basePath"` RecordingBaseFolder string Middleware []string `json:"middleware"` PreMiddleware []string `json:"pre-middleware"` JWTConfig *JWTConfig `json:"jwtConfig"` Config json.RawMessage `json:"config"` }
type APIInterface ¶
type APIInterface interface { AddPathConfig(path string, config *PathConfig) error AddConfig(config *APIConfig) error Initialize() error EchoInstance() *echo.Echo SetEchoInstance(e *echo.Echo) }
define an interface that all plugins must implement
type Context ¶
type Context struct { echo.Context // contains filtered or unexported fields }
func (*Context) RequestContext ¶
type JWTConfig ¶
type JWTConfig struct { Key string `json:"key"` //Signing key needed for validating token SigningKeys map[string]interface{} `json:"signingKeys"` //Key map used for validating token. Can be used in place of a single key Certificate []byte `json:"certificate"` CertificatePath string `json:"certificatePath"` //Path the signing certificate used to validate token. Can be used in place of a key JWKSUrl string `json:"jwksUrl"` //URL to JSON Web Key set. Can be used in place of a Key TokenLookup string `json:"tokenLookup"` Claims map[string]interface{} `json:"claims"` AuthScheme string `json:"authScheme"` ContextKey string `json:"contextKey"` SigningMethod string `json:"signingMethod"` }
type LoggerWrapper ¶
type LoggerWrapper struct {
// contains filtered or unexported fields
}
LoggerWrapper makes a WeOS compatible logger
func (LoggerWrapper) Debug ¶
func (l LoggerWrapper) Debug(args ...interface{})
func (LoggerWrapper) Debugf ¶
func (l LoggerWrapper) Debugf(format string, args ...interface{})
func (LoggerWrapper) Debugln ¶
func (l LoggerWrapper) Debugln(args ...interface{})
func (LoggerWrapper) Error ¶
func (l LoggerWrapper) Error(args ...interface{})
func (LoggerWrapper) Errorf ¶
func (l LoggerWrapper) Errorf(format string, args ...interface{})
func (LoggerWrapper) Errorln ¶
func (l LoggerWrapper) Errorln(args ...interface{})
func (LoggerWrapper) Fatal ¶
func (l LoggerWrapper) Fatal(args ...interface{})
func (LoggerWrapper) Fatalf ¶
func (l LoggerWrapper) Fatalf(format string, args ...interface{})
func (LoggerWrapper) Fatalln ¶
func (l LoggerWrapper) Fatalln(args ...interface{})
func (LoggerWrapper) Info ¶
func (l LoggerWrapper) Info(args ...interface{})
func (LoggerWrapper) Infof ¶
func (l LoggerWrapper) Infof(format string, args ...interface{})
func (LoggerWrapper) Infoln ¶
func (l LoggerWrapper) Infoln(args ...interface{})
func (LoggerWrapper) Panic ¶
func (l LoggerWrapper) Panic(args ...interface{})
func (LoggerWrapper) Panicf ¶
func (l LoggerWrapper) Panicf(format string, args ...interface{})
func (LoggerWrapper) Panicln ¶
func (l LoggerWrapper) Panicln(args ...interface{})
func (LoggerWrapper) Print ¶
func (l LoggerWrapper) Print(args ...interface{})
func (LoggerWrapper) Printf ¶
func (l LoggerWrapper) Printf(format string, args ...interface{})
func (LoggerWrapper) Println ¶
func (l LoggerWrapper) Println(args ...interface{})
func (LoggerWrapper) Trace ¶
func (l LoggerWrapper) Trace(args ...interface{})
func (LoggerWrapper) Tracef ¶
func (l LoggerWrapper) Tracef(format string, args ...interface{})
func (LoggerWrapper) Traceln ¶
func (l LoggerWrapper) Traceln(args ...interface{})
func (LoggerWrapper) Warn ¶
func (l LoggerWrapper) Warn(args ...interface{})
func (LoggerWrapper) Warnf ¶
func (l LoggerWrapper) Warnf(format string, args ...interface{})
func (LoggerWrapper) Warning ¶
func (l LoggerWrapper) Warning(args ...interface{})
func (LoggerWrapper) Warningf ¶
func (l LoggerWrapper) Warningf(format string, args ...interface{})
func (LoggerWrapper) Warningln ¶
func (l LoggerWrapper) Warningln(args ...interface{})
func (LoggerWrapper) Warnln ¶
func (l LoggerWrapper) Warnln(args ...interface{})
func (LoggerWrapper) WithField ¶
func (l LoggerWrapper) WithField(key string, value interface{}) *log.Entry
func (LoggerWrapper) WithFields ¶
func (l LoggerWrapper) WithFields(fields log.Fields) *log.Entry
type PathConfig ¶
type PathConfig struct { Handler string `json:"handler" ,yaml:"handler"` Group bool `json:"group" ,yaml:"group"` Middleware []string `json:"middleware"` Config json.RawMessage `json:"config"` DisableCors bool `json:"disable-cors"` AllowedHeaders []string `json:"allowed-headers" ,yaml:"allowed-headers"` AllowedOrigins []string `json:"allowed-origins" ,yaml:"allowed-origins"` }
type StaticConfig ¶
type StaticConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // Root directory from where the static content is served. // Required. Root string `yaml:"root"` // Index file for serving a directory. // Optional. Default value "index.html". Index string `yaml:"index"` // Enable HTML5 mode by forwarding all not-found requests to root so that // SPA (single-page application) can handle the routing. // Optional. Default value false. HTML5 bool `yaml:"html5"` // Enable directory browsing. // Optional. Default value false. Browse bool `yaml:"browse"` // Enable ignoring of the base of the URL path. // Example: when assigning a static middleware to a non root path group, // the filesystem path is not doubled // Optional. Default value false. IgnoreBase bool `yaml:"ignoreBase"` FileSystem *embed.FS }
StaticConfig defines the config for Static middleware.