app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.5.0

type Config struct {
	Port uint16    `json:"port"`
	DB   db.Config `json:"db"`
}

Config for the main application.

func LoadConfig added in v0.5.0

func LoadConfig(path string) (Config, error)

LoadConfig loads the config.

func (Config) Validate added in v0.5.0

func (conf Config) Validate() error

Validate validates the config.

type Context added in v0.5.0

type Context struct {
	echo.Context
}

Context represents the context of the current HTTP request.

func (*Context) BadRequest added in v0.5.0

func (c *Context) BadRequest(message string) error

BadRequest sends an error response with status code 400.

func (*Context) InternalServerError added in v0.5.0

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

InternalServerError sends an error response with status code 500.

func (*Context) NotFound added in v0.5.0

func (c *Context) NotFound(message string) error

NotFound sends an error response with status code 404.

func (*Context) Success added in v0.5.0

func (c *Context) Success(v interface{}) error

Success sends a JSON response with status code 200.

func (*Context) SuccessWithEmpty added in v0.5.0

func (c *Context) SuccessWithEmpty() error

SuccessWithEmpty sends an empty JSON response with status code 200.

type Env added in v0.5.0

type Env struct {
	DB     *sql.DB
	Config Config
}

Env holds some application-level objects.

func NewEnv added in v0.5.0

func NewEnv(conf Config) (*Env, error)

NewEnv creates an instance of Env.

type HandlerFunc added in v0.5.0

type HandlerFunc func(env *Env, c *Context) error

HandlerFunc is a function to serve HTTP requests.

Jump to

Keyboard shortcuts

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