server

package
v0.0.0-...-337a1ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseStateSuccess = "success"
	ResponseStateError   = "error"
)

Variables

View Source
var (
	ErrUnknownLogLevel = errors.New("Unknown log level")
)

Functions

This section is empty.

Types

type Apps

type Apps struct {
	Auth auth.Application
	User user.Application
}

type Config

type Config struct {
	Port          int                 `json:"port"`
	IndexFilePath string              `json:"index_file_path"`
	StaticDirPath string              `json:"static_dir_path"`
	LogLevel      string              `json:"log_level"`
	App           *application.Config `json:"app"`
}

func (*Config) Address

func (conf *Config) Address() string

func (*Config) LogLvl

func (conf *Config) LogLvl() log.Lvl

func (*Config) Validate

func (conf *Config) Validate() error

type Context

type Context struct {
	echo.Context
	Apps *Apps
}

func (*Context) Claims

func (c *Context) Claims() *metamask.Claims

func (*Context) JSONError

func (c *Context) JSONError(err error) error

func (*Context) JSONSuccess

func (c *Context) JSONSuccess(result interface{}) error

type Controller

type Controller struct {
	*echo.Group
	*Core
}

func (*Controller) Add

func (cntl *Controller) Add(method, path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Controller) Child

func (cntl *Controller) Child(prefix string) *Controller

func (*Controller) DELETE

func (cntl *Controller) DELETE(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Controller) GET

func (cntl *Controller) GET(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Controller) NewContext

func (cntl *Controller) NewContext(c echo.Context) *Context

func (*Controller) POST

func (cntl *Controller) POST(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Controller) PUT

func (cntl *Controller) PUT(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

type Core

type Core struct {
	Config *Config
	Apps   *Apps
}

type HandlerFunc

type HandlerFunc func(*Context) error

type Response

type Response struct {
	State  string      `json:"state"`
	Result interface{} `json:"result"`
}

func NewErrorResponse

func NewErrorResponse(err *domain.Error) *Response

func NewSuccessResponse

func NewSuccessResponse(result interface{}) *Response

type Server

type Server struct {
	*Controller
	// contains filtered or unexported fields
}

func New

func New(core *Core) *Server

func (*Server) Base

func (srv *Server) Base() *Controller

func (*Server) Logger

func (srv *Server) Logger() echo.Logger

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (srv *Server) Start() error

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL