app

package
v0.0.0-...-e520e56 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Config   *Config
	Database *db.Database
}

func New

func New() (app *App, err error)

func (*App) Close

func (a *App) Close() error

func (*App) GetUserByEmail

func (a *App) GetUserByEmail(email string) (*model.User, error)

func (*App) NewContext

func (a *App) NewContext() *Context

type Config

type Config struct {
	// A secret string used for session cookies, passwords, etc.
	SecretKey []byte
}

func InitConfig

func InitConfig() (*Config, error)

type Context

type Context struct {
	Logger        logrus.FieldLogger
	RemoteAddress string
	Database      *db.Database
	User          *model.User
}

func (*Context) AuthorizationError

func (ctx *Context) AuthorizationError() *UserError

func (*Context) CreateTodo

func (ctx *Context) CreateTodo(todo *model.Todo) error

func (*Context) CreateUser

func (ctx *Context) CreateUser(user *model.User, password string) error

func (*Context) DeleteTodoById

func (ctx *Context) DeleteTodoById(id uint) error

func (*Context) GetTodoById

func (ctx *Context) GetTodoById(id uint) (*model.Todo, error)

func (*Context) GetUserTodos

func (ctx *Context) GetUserTodos() ([]*model.Todo, error)

func (*Context) UpdateTodo

func (ctx *Context) UpdateTodo(todo *model.Todo) error

func (*Context) WithLogger

func (ctx *Context) WithLogger(logger logrus.FieldLogger) *Context

func (*Context) WithRemoteAddress

func (ctx *Context) WithRemoteAddress(address string) *Context

func (*Context) WithUser

func (ctx *Context) WithUser(user *model.User) *Context

type UserError

type UserError struct {
	Message    string `json:"message"`
	StatusCode int    `json:"-"`
}

func (*UserError) Error

func (e *UserError) Error() string

type ValidationError

type ValidationError struct {
	Message string `json:"message"`
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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