yoda

package module
v0.3.0 Latest Latest
Warning

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

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

README

yoda

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer added in v0.2.0

func NewServer(config Config) *yoda

Creates a new standard yoda server

func NewServerWithConfig added in v0.2.0

func NewServerWithConfig(config atreugo.Config) *yoda

Creates a yoda server with config

Types

type Config added in v0.2.0

type Config struct {
	Addr         string
	Name         string
	CORS         cors.Config
	IdleTimeout  time.Duration
	WriteTimeout time.Duration
	ReadTimeout  time.Duration
}

Config

type Context added in v0.2.0

type Context struct {
	Parent *atreugo.RequestCtx
}

Context struct

func (*Context) Bind added in v0.2.0

func (c *Context) Bind(i interface{}) error

Binds a json into a struct

func (*Context) BindWithValidator added in v0.3.0

func (c *Context) BindWithValidator(i interface{}, key string, fn validator.Func) error

Binds a json with custom validaroe

func (*Context) Error added in v0.2.0

func (c *Context) Error(err vader.Error) error

Creates a JSON response with an error

func (*Context) FromContext added in v0.2.0

func (c *Context) FromContext(key string) interface{}

Returns a value from a context using the key

func (*Context) GetHeader added in v0.2.0

func (c *Context) GetHeader(key string) []byte

Get a header value

func (*Context) JSON added in v0.2.0

func (c *Context) JSON(status int, obj interface{}) error

Creates a JSON response

func (*Context) Message added in v0.3.0

func (c *Context) Message(status int, message string) error

Creates a default response with a message

func (*Context) Next added in v0.2.0

func (c *Context) Next() error

Next function

type Handler added in v0.2.0

type Handler func(*Context) error

Handler

type Response

type Response struct {
	Message string      `json:"message,omitempty"`
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

Response struct

type Router added in v0.2.0

type Router struct {
	Parent *atreugo.Router
}

Router struct

func (*Router) Delete added in v0.2.0

func (r *Router) Delete(path string, handler Handler)

DELETE

func (*Router) Get added in v0.2.0

func (r *Router) Get(path string, handler Handler)

GET

func (*Router) Patch added in v0.2.0

func (r *Router) Patch(path string, handler Handler)

PATCH

func (*Router) Post added in v0.2.0

func (r *Router) Post(path string, handler Handler)

POST

func (*Router) Put added in v0.2.0

func (r *Router) Put(path string, handler Handler)

PUT

func (*Router) Use added in v0.2.0

func (r *Router) Use(middlewares ...Handler)

Append middlewares to router

type Yoda

type Yoda interface {
	Run()
}

Server interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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