yoda

package module
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 10 Imported by: 2

README

Go Report Card GoDev GitHub release

Yoda web framework

built on top of atreugo.

Example server on localhost:8080:

srv := yoda.NewServer(yoda.Config{
	Addr:   ":8080",
	Name:   "server",
})

group := srv.Group("/group")

group.Get("/create", func (ctx *yoda.Context) error {
    return ctx.JSON(200, "")
})

srv.StartServer()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 struct

type Context added in v0.2.0

type Context struct {
	Parent *atreugo.RequestCtx
}

Context struct

func (*Context) AttachContext added in v0.4.7

func (c *Context) AttachContext(context context.Context)

AttachContext adds a new context to the current one

func (*Context) AttachedContext added in v0.4.7

func (c *Context) AttachedContext() context.Context

AttachedContext returns the attached context

func (*Context) Bind added in v0.2.0

func (c *Context) Bind(i interface{}) vader.Error

Bind 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) vader.Error

BindWithValidator binds a json with custom validaroe

func (*Context) Error added in v0.2.0

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

Error creates a JSON response with an error

func (*Context) FromContext added in v0.2.0

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

FromContext returns a value from a context using the key

func (*Context) GetHeader added in v0.2.0

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

GetHeader returns an specific value of a given key

func (*Context) GetValue added in v0.4.7

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

GetValue gets the value set by SetValue

func (*Context) JSON added in v0.2.0

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

JSON creates a JSON response

func (*Context) Message added in v0.3.0

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

Message creates a default response with a message

func (*Context) Next added in v0.2.0

func (c *Context) Next() error

Next function

func (*Context) Param added in v0.4.4

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

Param returns the value of a given param

func (*Context) Query added in v0.4.4

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

Query returns the value of a given query key

func (*Context) SetValue added in v0.4.7

func (c *Context) SetValue(key string, value interface{})

SetValue sets a value with a given key

type Handler added in v0.2.0

type Handler func(*Context) error

Handler struct

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, middlewares ...Handler)

Delete creates a listener of DELETE requests

func (*Router) Get added in v0.2.0

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

Get creates a listener of GET requests

func (*Router) Patch added in v0.2.0

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

PATCH creates a listener of PATCH requests

func (*Router) Post added in v0.2.0

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

Post creates a listener of POST requests

func (*Router) Put added in v0.2.0

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

Put creates a listener of PUT requests

func (*Router) Use added in v0.2.0

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

Use appends middlewares to router

type Yoda

type Yoda struct {
	*atreugo.Atreugo
	// contains filtered or unexported fields
}

Server struct

func NewServer added in v0.2.0

func NewServer(config Config) *Yoda

NewServer creates a new standard yoda server

func NewServerWithConfig added in v0.2.0

func NewServerWithConfig(config atreugo.Config) *Yoda

NewServerWithConfig creates a yoda server with config

func (*Yoda) Group added in v0.4.2

func (y *Yoda) Group(path string, fns ...Handler) *Router

Group creates a group

func (*Yoda) Start added in v0.4.2

func (y *Yoda) Start() error

Start starts the yoda server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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