gowebapp

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: GPL-3.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStatusCode0Invalid = errors.New("0 is not a valid code")
)

Functions

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, msg string) error

RespondWithError return error message as JSON format. Eg: {"message": "Access denied for user 'root'"}

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{}) error

RespondWithJSON sends the response "payload" as JSON format to the client with code as status code.

func URLParam

func URLParam(r *http.Request, key string) string

URLParam returns the url parameter from a http.Request object.

Types

type Router

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

func (*Router) Connect

func (r *Router) Connect(pattern string, handler http.HandlerFunc)

func (*Router) Delete

func (r *Router) Delete(pattern string, handler http.HandlerFunc)

func (*Router) Get

func (r *Router) Get(pattern string, handler http.HandlerFunc)

func (*Router) Group

func (r *Router) Group(pattern string) *RouterGroup

func (*Router) Head

func (r *Router) Head(pattern string, handler http.HandlerFunc)

func (*Router) Method

func (r *Router) Method(method string, pattern string, handler http.HandlerFunc)

func (*Router) Options

func (r *Router) Options(pattern string, handler http.HandlerFunc)

func (*Router) Patch

func (r *Router) Patch(pattern string, handler http.HandlerFunc)

func (*Router) Post

func (r *Router) Post(pattern string, handler http.HandlerFunc)

func (*Router) Put

func (r *Router) Put(pattern string, handler http.HandlerFunc)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Trace

func (r *Router) Trace(pattern string, handler http.HandlerFunc)

type RouterGroup

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

func (*RouterGroup) Connect

func (r *RouterGroup) Connect(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Delete

func (r *RouterGroup) Delete(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Get

func (r *RouterGroup) Get(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Head

func (r *RouterGroup) Head(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Method

func (r *RouterGroup) Method(method string, pattern string, handler http.HandlerFunc)

func (*RouterGroup) Options

func (r *RouterGroup) Options(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Patch

func (r *RouterGroup) Patch(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Post

func (r *RouterGroup) Post(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Put

func (r *RouterGroup) Put(pattern string, handler http.HandlerFunc)

func (*RouterGroup) Trace

func (r *RouterGroup) Trace(pattern string, handler http.HandlerFunc)

type Scope

type Scope struct {
	Environment string
}

type WebApp

type WebApp struct {
	*Router
	Scope
}

func NewWebApp

func NewWebApp(environment string) *WebApp

func (*WebApp) Run

func (wa *WebApp) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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