api

package
v0.0.0-...-6b52c20 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: Apache-2.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegisteredAPIFuncHandler map[string]func(http.ResponseWriter, *http.Request)
View Source
var RegisteredAPIHandler map[string]http.Handler
View Source
var RegisteredAPIMethodHandler map[string]map[string]func(w http.ResponseWriter, req *http.Request, ps httprouter.Params)
View Source
var RegisteredUIFuncHandler map[string]func(http.ResponseWriter, *http.Request)
View Source
var RegisteredUIHandler map[string]http.Handler
View Source
var RegisteredUIMethodHandler map[string]map[string]func(w http.ResponseWriter, req *http.Request, ps httprouter.Params)

Functions

func BasicAuth

func BasicAuth(h httprouter.Handle, requiredUser, requiredPassword string) httprouter.Handle

func GetFlash

func GetFlash(w http.ResponseWriter, r *http.Request) (bool, []interface{})

func GetSession

func GetSession(w http.ResponseWriter, r *http.Request, key string) (bool, interface{})

func HandleAPI

func HandleAPI(pattern string, handler http.Handler)

func HandleAPIFunc

func HandleAPIFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

func HandleAPIMethod

func HandleAPIMethod(method Method, pattern string, handler func(w http.ResponseWriter, req *http.Request, ps httprouter.Params))

func HandleUI

func HandleUI(pattern string, handler http.Handler)

func HandleUIFunc

func HandleUIFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

func HandleUIMethod

func HandleUIMethod(method Method, pattern string, handler func(w http.ResponseWriter, req *http.Request, ps httprouter.Params))

func SetFlash

func SetFlash(w http.ResponseWriter, r *http.Request, msg string) bool

func SetSession

func SetSession(w http.ResponseWriter, r *http.Request, key string, value interface{}) bool

Types

type ErrEmptyJson

type ErrEmptyJson struct {
}

type Handler

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

func (Handler) EncodeJson

func (w Handler) EncodeJson(v interface{}) (b []byte, err error)

func (Handler) Error

func (this Handler) Error(w http.ResponseWriter, err error)

func (Handler) Error404

func (this Handler) Error404(w http.ResponseWriter)

func (Handler) Error500

func (this Handler) Error500(w http.ResponseWriter, msg string)

func (Handler) Flush

func (this Handler) Flush(w http.ResponseWriter)

func (Handler) Get

func (this Handler) Get(req *http.Request, key string, defaultValue string) string

func (Handler) GetIntOrDefault

func (this Handler) GetIntOrDefault(r *http.Request, key string, defaultValue int) int

func (Handler) GetJson

func (this Handler) GetJson(r *http.Request) (*jsonq.JsonQuery, error)

func (Handler) GetParameter

func (this Handler) GetParameter(r *http.Request, key string) string

func (Handler) GetParameterOrDefault

func (this Handler) GetParameterOrDefault(r *http.Request, key string, defaultValue string) string

func (Handler) GetRawBody

func (this Handler) GetRawBody(r *http.Request) ([]byte, error)

func (Handler) Write

func (this Handler) Write(w http.ResponseWriter, b []byte) (int, error)

func (Handler) WriteHeader

func (this Handler) WriteHeader(w http.ResponseWriter, code int)

func (Handler) WriteJson

func (this Handler) WriteJson(w http.ResponseWriter, v interface{}, statusCode int) error

func (Handler) WriteJsonHeader

func (this Handler) WriteJsonHeader(w http.ResponseWriter)

func (Handler) WriteListResultJson

func (this Handler) WriteListResultJson(w http.ResponseWriter, total int, v interface{}, statusCode int) error

type Method

type Method string
const (
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	DELETE Method = "DELETE"
	HEAD   Method = "HEAD"
)

func (Method) String

func (this Method) String() string

type Result

type Result struct {
	Total  int         `json:"total"`
	Result interface{} `json:"result"`
}

Jump to

Keyboard shortcuts

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