handlers

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 17 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

Functions

func CreateSource

func CreateSource(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

CreateSource creates a source -> /source/create

func ListSources

func ListSources(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

ListSources lists sources -> /sources

func LogError

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

LogError returns true on error

func Login

func Login(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

Login login handler -> /user/login

func NewRouter

func NewRouter(db *dbhelper.DBhelper, config *models.ConfigStruct, ownIP *string, callback models.SubscriberNotifyCallback) *mux.Router

NewRouter create new router

func Register

func Register(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

Register register handler -> /user/create

func RouteHandler

func RouteHandler(db *dbhelper.DBhelper, requestType requestType, handlerData *handlerData, inner RouteFunction, name string) http.Handler

RouteHandler logs stuff

func Subscribe

func Subscribe(db *dbhelper.DBhelper, handler handlerData, w http.ResponseWriter, r *http.Request)

Subscribe subscription handler -> /sub/add

func Unsubscribe

func Unsubscribe(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

Unsubscribe unsubscribe handler -> /sub/remove

func UpdateCallbackURL

func UpdateCallbackURL(db *dbhelper.DBhelper, handler handlerData, w http.ResponseWriter, r *http.Request)

UpdateCallbackURL update subscription url handler -> /sub/updateCallbackURL

func UpdateSource

func UpdateSource(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

UpdateSource updates a source -> /source/update/{action}

func WebhookHandler

func WebhookHandler(db *dbhelper.DBhelper, handlerData handlerData, w http.ResponseWriter, r *http.Request)

WebhookHandler handler for incoming webhooks -> /post/webhook

Types

type AuthHandler

type AuthHandler struct {
	Request *http.Request
	// contains filtered or unexported fields
}

AuthHandler handler for http auth

func NewAuthHandler

func NewAuthHandler(request *http.Request, db *dbhelper.DBhelper) *AuthHandler

NewAuthHandler returns a new AuthHandler

func (AuthHandler) GetBearer

func (authHandler AuthHandler) GetBearer() string

GetBearer return the bearer token

func (AuthHandler) GetUserFromBearer

func (authHandler AuthHandler) GetUserFromBearer() (*models.User, error)

GetUserFromBearer returns the User assigned to the 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"
	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(*dbhelper.DBhelper, handlerData, http.ResponseWriter, *http.Request)

RouteFunction function for handling a route

type Routes

type Routes []Route

Routes all REST routes

Jump to

Keyboard shortcuts

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