web

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	http.Handler
	// contains filtered or unexported fields
}

func NewApp

func NewApp() *App

func (*App) Any added in v0.0.2

func (app *App) Any(path string, routeHandler RouteHandler) *App

func (*App) Configure added in v1.0.2

func (app *App) Configure(opts ConfigureOptions)

func (*App) Delete

func (app *App) Delete(path string, routeHandler RouteHandler) *App

func (*App) Get

func (app *App) Get(path string, routeHandler RouteHandler) *App

func (*App) HandleError

func (app *App) HandleError(router *Router, ctx Context, err error)

HandleError recovers from panics gracefully and calls

func (*App) HandleMethod

func (app *App) HandleMethod(methods []string, path string, routeHandler RouteHandler) *App

func (*App) Init added in v0.0.8

func (app *App) Init()

func (*App) Patch

func (app *App) Patch(path string, routeHandler RouteHandler) *App

func (*App) Post

func (app *App) Post(path string, routeHandler RouteHandler) *App

func (*App) Put

func (app *App) Put(path string, routeHandler RouteHandler) *App

func (*App) RendererEngine added in v1.0.2

func (app *App) RendererEngine() renderer.Engine

func (*App) Resource added in v0.0.2

func (app *App) Resource(path string, resource Resource) *App

func (*App) Router added in v0.0.8

func (app *App) Router(path string, opts ...RouterOption) *Router

func (*App) ServeHTTP

func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*App) StartWebpackServer added in v1.0.2

func (app *App) StartWebpackServer()

func (*App) Use added in v0.0.5

func (app *App) Use(mw ...MiddlewareFunc)

func (*App) UsePrepend added in v1.0.2

func (app *App) UsePrepend(mw ...MiddlewareFunc)

type ConfigureOptions added in v1.0.2

type ConfigureOptions struct {
	Logger          logger.Logger
	Env             string
	WebpackEnabled  bool
	TmplEngine      renderer.Engine
	SessionName     string
	SessionStore    sessions.Store
	SessionSameSite string
	PluginInstances map[string]interface{}
	SessionSecret   string
	DB              *gorm.DB
}

type Context

type Context interface {
	context.Context
	Request() *http.Request
	Response() http.ResponseWriter
	Params() map[string]string
	Set(string, interface{})
	SetStatus(status int) Context
	GetStatus() int
	Render(template string) error
	RenderJson(data interface{}) error
	Redirect(url string) error
	Logger() logger.Logger
	Cookies() *Cookies
	Session() *Session
	PluginInstance(name string) interface{}
	DB() *gorm.DB
}

type Cookies

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

func (*Cookies) Delete

func (c *Cookies) Delete(name string)

Delete a cookie

func (*Cookies) Get

func (c *Cookies) Get(name string) (string, error)

Get a cookie from name

func (*Cookies) Set

func (c *Cookies) Set(name, value string, maxAge time.Duration)

Set a cookie on the response, which will expire after the given duration.

func (*Cookies) SetWithExpirationTime

func (c *Cookies) SetWithExpirationTime(name, value string, expires time.Time)

SetWithExpirationTime sets a cookie that will expire at a specific time.

func (*Cookies) SetWithPath

func (c *Cookies) SetWithPath(name, value, path string)

SetWithPath sets a cookie path on the server in which the cookie will be available on.

type DefaultContext

type DefaultContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewDefaultContext

func NewDefaultContext() *DefaultContext

func (*DefaultContext) Cookies

func (d *DefaultContext) Cookies() *Cookies

Retrieve request session instance

func (*DefaultContext) DB added in v1.0.2

func (d *DefaultContext) DB() *gorm.DB

func (*DefaultContext) GetStatus added in v0.0.10

func (d *DefaultContext) GetStatus() int

GetStatus get the current context status

func (*DefaultContext) Logger

func (d *DefaultContext) Logger() logger.Logger

Logger is the logger instance from zepto

func (*DefaultContext) Params

func (d *DefaultContext) Params() map[string]string

Retrieve a map of URL parameters

func (*DefaultContext) PluginInstance added in v1.0.2

func (d *DefaultContext) PluginInstance(name string) interface{}

func (*DefaultContext) Redirect added in v0.0.2

func (d *DefaultContext) Redirect(url string) error

Redirect to url

func (*DefaultContext) Render

func (d *DefaultContext) Render(template string) error

Render a template

func (*DefaultContext) RenderJson

func (d *DefaultContext) RenderJson(data interface{}) error

Render a json

func (*DefaultContext) Request added in v0.0.2

func (d *DefaultContext) Request() *http.Request

Request is the http request

func (*DefaultContext) Response added in v0.0.2

func (d *DefaultContext) Response() http.ResponseWriter

Response is the http response writer

func (*DefaultContext) Session

func (d *DefaultContext) Session() *Session

Retrieve request session instance

func (*DefaultContext) Set

func (d *DefaultContext) Set(key string, value interface{})

Set a value to context. The values defined here are accessible in the template

func (*DefaultContext) SetStatus

func (d *DefaultContext) SetStatus(s int) Context

SetStatus set a http status code before render

func (*DefaultContext) Value

func (d *DefaultContext) Value(key interface{}) interface{}

Value returns a value from context

type MiddlewareFunc added in v0.0.5

type MiddlewareFunc func(RouteHandler) RouteHandler

type MiddlewareStack added in v0.0.5

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

func (*MiddlewareStack) Use added in v0.0.5

func (ms *MiddlewareStack) Use(mw ...MiddlewareFunc)

func (*MiddlewareStack) UsePrepend added in v1.0.2

func (ms *MiddlewareStack) UsePrepend(mw ...MiddlewareFunc)

type MuxHandler

type MuxHandler func(w http.ResponseWriter, r *http.Request)

type Options

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

type Resource added in v0.0.2

type Resource interface {
	List(Context) error
	Show(Context) error
	Create(Context) error
	Update(Context) error
	Destroy(Context) error
}

type RouteHandler

type RouteHandler func(ctx Context) error

type Router added in v0.0.8

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

func NewRouter added in v0.0.8

func NewRouter(path string, opts ...RouterOption) *Router

func (*Router) Any added in v0.0.8

func (router *Router) Any(path string, routeHandler RouteHandler) *Router

func (*Router) Delete added in v0.0.8

func (router *Router) Delete(path string, routeHandler RouteHandler) *Router

func (*Router) Get added in v0.0.8

func (router *Router) Get(path string, routeHandler RouteHandler) *Router

func (*Router) HandleMethod added in v0.0.8

func (router *Router) HandleMethod(methods []string, path string, routeHandler RouteHandler) *Router

func (*Router) Patch added in v0.0.8

func (router *Router) Patch(path string, routeHandler RouteHandler) *Router

func (*Router) Post added in v0.0.8

func (router *Router) Post(path string, routeHandler RouteHandler) *Router

func (*Router) Put added in v0.0.8

func (router *Router) Put(path string, routeHandler RouteHandler) *Router

func (*Router) Resource added in v0.0.10

func (router *Router) Resource(path string, resource Resource) *Router

func (*Router) Use added in v0.0.8

func (router *Router) Use(mw ...MiddlewareFunc)

func (*Router) UsePrepend added in v1.0.2

func (router *Router) UsePrepend(mw ...MiddlewareFunc)

type RouterHandler added in v0.0.8

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

type RouterOption added in v0.0.8

type RouterOption func(*routerOptions)

func Hosts added in v0.0.8

func Hosts(hosts ...string) RouterOption

type Session

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

func (*Session) Clear

func (s *Session) Clear()

func (*Session) Delete

func (s *Session) Delete(key interface{})

func (*Session) Get

func (s *Session) Get(key interface{}) interface{}

func (*Session) Save

func (s *Session) Save() error

func (*Session) Set

func (s *Session) Set(key, value interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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