simplex

package
v0.0.0-...-2847b59 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 9 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 {
	// contains filtered or unexported fields
}

func New

func New() *App

func (*App) Config

func (app *App) Config() *Config

func (*App) Delete

func (app *App) Delete(pattern string, handler HandlerFunc)

func (*App) Get

func (app *App) Get(pattern string, handler HandlerFunc)

func (*App) Patch

func (app *App) Patch(pattern string, handler HandlerFunc)

func (*App) Post

func (app *App) Post(pattern string, handler HandlerFunc)

func (*App) Put

func (app *App) Put(pattern string, handler HandlerFunc)

func (*App) Run

func (app *App) Run()

func (*App) ServeHTTP

func (app *App) ServeHTTP(res http.ResponseWriter, req *http.Request)

func (*App) Use

func (app *App) Use(h ...HandlerFunc)

type Config

type Config struct {
	Addr string
}

func LoadConfig

func LoadConfig() *Config

type Context

type Context struct {
	Request *http.Request

	Response http.ResponseWriter

	// The application
	App *App

	// Did we already sent the response?
	DidSent bool
	// contains filtered or unexported fields
}

func NewContext

func NewContext(res http.ResponseWriter, req *http.Request, app *App) *Context

NewContext creates a Golf.Context instance.

func (*Context) AddHeader

func (ctx *Context) AddHeader(key, value string)

func (*Context) ContentType

func (ctx *Context) ContentType(contentType string)

ContentType sets content-type string.

func (*Context) GetHeader

func (ctx *Context) GetHeader(key string) string

func (*Context) Json

func (ctx *Context) Json(data interface{})

Json set json response with data and proper header.

func (*Context) Query

func (ctx *Context) Query(key string, index ...int) (string, error)

func (*Context) Redirect

func (ctx *Context) Redirect(url string)

Redirect method sets the response as a 302 redirection.

func (*Context) Send

func (ctx *Context) Send(body interface{})

Send the response immediately. Set `ctx.IsSent` to `true` to make sure that the response won't be sent twice.

func (*Context) SendStatus

func (ctx *Context) SendStatus(statusCode int)

func (*Context) SetHeader

func (ctx *Context) SetHeader(key, value string)

func (*Context) StatusCode

func (ctx *Context) StatusCode() int

type HandlerFunc

type HandlerFunc func(ctx *Context)

type RoutePath

type RoutePath struct {
	// contains filtered or unexported fields
}

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

NewRouter returns new router instance.

func (*Router) MatchRoute

func (rt *Router) MatchRoute(url string, method string) (*RoutePath, error)

func (*Router) Route

func (rt *Router) Route(pattern string, method string, handler HandlerFunc) *RoutePath

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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