Documentation ¶
Overview ¶
Package gobase is a web framework with basic settings and structure, wrapping labstack/echo.
Example:
package main import ( "net/http" "github.com/cancue/gobase" "github.com/labstack/echo/v4/middleware" ) // Handler func hello(c gobase.Context) error { return c.String(http.StatusOK, "Hello, World!") } func main() { // Gobase instance g := gobase.NewWithConfig(gobase.Config{ Stage: "local", Name: "gobase-example", Port: 65535, ReadTimeout: 0, WriteTimeout: 0, }) // Middleware g.Use(middleware.Secure()) // Routes g.GET("/", hello) // Start server g.Start() }
You may want to check out https://github.com/cancue/gobase-demo
Index ¶
- Variables
- func Controller(obj interface{}) func(echo.Context) error
- func NewInvalidErrorMap(err error) interface{}
- type Config
- type Context
- type Server
- func (s *Server) DELETE(path string, controller echo.HandlerFunc, m ...echo.MiddlewareFunc)
- func (s *Server) GET(path string, controller echo.HandlerFunc, m ...echo.MiddlewareFunc)
- func (s *Server) POST(path string, controller echo.HandlerFunc, m ...echo.MiddlewareFunc)
- func (s *Server) PUT(path string, controller echo.HandlerFunc, m ...echo.MiddlewareFunc)
- func (s *Server) Routes() (data []byte, err error)
- func (s *Server) Start()
- func (s *Server) Use(middleware ...echo.MiddlewareFunc)
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// NewHTTPError is an alias for labstack/echo.
NewHTTPError = echo.NewHTTPError
)
View Source
var ( // Validator is an alias for go-playground/validator Validator *validation.Validate )
Functions ¶
func Controller ¶
func Controller(obj interface{}) func(echo.Context) error
Controller returns controller from a struct written in suggested form.
func NewInvalidErrorMap ¶
func NewInvalidErrorMap(err error) interface{}
NewInvalidErrorMap returns rich error message.
Types ¶
type Config ¶
type Config struct { Stage string Name string Port string ReadTimeout time.Duration WriteTimeout time.Duration HTTPRequestLogger bool }
Config defines the config for Server.
type Server ¶
type Server struct { Config *Config Logger *logrus.Logger // contains filtered or unexported fields }
Server is the top-level framework instance.
func NewWithConfig ¶
NewWithConfig returns server with CustomConfig.
type ValidationError ¶
type ValidationError struct { Message string `json:"message"` InvalidFields []map[string]string `json:"invalidFields"` }
ValidationError describes the error information in the format for the end user.
Click to show internal directories.
Click to hide internal directories.