handlers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrorTokenInvalid error if token is invalid
	ErrorTokenInvalid error = errors.New("Token invalid")
	//ErrorTokenEmpty error if token is empty
	ErrorTokenEmpty error = errors.New("Token empty")
)
View Source
var AllowedSchemes = []string{"http", "https"}

AllowedSchemes schemes that are allowed in urls

View Source
var (
	// ErrMissingFile error if file is missing
	ErrMissingFile = errors.New("missing upload file")
)

Functions

func AttributeHandler

func AttributeHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

AttributeHandler handler for attributes

func FileHandler

func FileHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

FileHandler handler for updating files

func ListFilesHandler

func ListFilesHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

ListFilesHandler handler for listing files

func LogError

func LogError(err error, context ...map[string]interface{}) bool

LogError returns true on error

func Login

func Login(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

Login login handler -> /user/login

func NamespaceActionHandler

func NamespaceActionHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

NamespaceActionHandler handler for namespace actions (create/update/delete)

func NamespaceListHandler

func NamespaceListHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

NamespaceListHandler lists namespaces

func NewRouter

func NewRouter(config *models.Config, db *gorm.DB) *mux.Router

NewRouter create new router

func Ping

func Ping(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

Ping handles ping request

func Register

func Register(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

Register register handler -> /user/create

func RouteHandler

func RouteHandler(requestType requestType, handlerData *web.HandlerData, inner RouteFunction, name string) http.Handler

RouteHandler logs stuff

func UploadfileHandler

func UploadfileHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

UploadfileHandler handler for uploading files

func UserAttributeHandler added in v1.1.0

func UserAttributeHandler(handlerData web.HandlerData, w http.ResponseWriter, r *http.Request)

UserAttributeHandler handler for getting user attribute informations

Types

type AuthHandler

type AuthHandler struct {
	Request *http.Request
}

AuthHandler handler for http auth

func NewAuthHandler

func NewAuthHandler(request *http.Request) *AuthHandler

NewAuthHandler returns a new AuthHandler

func (AuthHandler) GetBearer

func (authHandler AuthHandler) GetBearer() string

GetBearer return the bearer token

func (AuthHandler) IsInvalid

func (authHandler AuthHandler) IsInvalid(err error) bool

IsInvalid return true if err is invalid

type HTTPMethod

type HTTPMethod string

HTTPMethod http method. GET, POST, DELETE, HEADER, etc...

const (
	GetMethod    HTTPMethod = "GET"
	POSTMethod   HTTPMethod = "POST"
	PUTMethod    HTTPMethod = "PUT"
	DeleteMethod HTTPMethod = "DELETE"
)

HTTP methods

type Route

type Route struct {
	Name        string
	Method      HTTPMethod
	Pattern     string
	HandlerFunc RouteFunction
	HandlerType requestType
}

Route for REST

type RouteFunction

type RouteFunction func(web.HandlerData, http.ResponseWriter, *http.Request)

RouteFunction function for handling a route

type Routes

type Routes []Route

Routes all REST routes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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