web

package
v0.0.0-...-f077983 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexHandler

func IndexHandler(w http.ResponseWriter, r *http.Request)

Showing info about API

func InfoHeadersHandler

func InfoHeadersHandler(next http.Handler) http.Handler

InfoHeadersHandler is a dummy middleware to add extra headers to the response

func JSONRenderingHandler

func JSONRenderingHandler(next http.Handler) http.Handler

JSONRenderingHandler sets application/json as content-type. This helps some typing inside of the individual handlers.

func LoggingHandler

func LoggingHandler(next http.Handler) http.Handler

LoggingHandler implements simple logging middleware to log incoming requests (to be extended further)

func NewAuthenticationHandler

func NewAuthenticationHandler(interactor usecases.SessionInteractor) func(next http.Handler) http.Handler

NewAuthenticationHandler create a new handler that handles token-based authentication

func NewContentTypeHandler

func NewContentTypeHandler(contentTypes ...string) func(next http.Handler) http.Handler

NewContentTypeHandler creates a middleware that validates the request content type is acompatible with the provided contentTypes list. It writes a HTTP 415 error if that fails. Only PUT, POST, and PATCH requests are considered.

func RecoverHandler

func RecoverHandler(next http.Handler) http.Handler

RecoverHandler recovers after the panic in the chain, return 500 error and log the error.

Types

type DomainWebHandler

type DomainWebHandler struct {
	DomainInteractor usecases.DomainInteractor
}

DomainWebHandler is a collection of CRUD methods for Users API

func (*DomainWebHandler) Create

func (handler *DomainWebHandler) Create(w http.ResponseWriter, r *http.Request)

func (*DomainWebHandler) Delete

func (handler *DomainWebHandler) Delete(w http.ResponseWriter, r *http.Request)

func (*DomainWebHandler) List

func (handler *DomainWebHandler) List(w http.ResponseWriter, r *http.Request)

func (*DomainWebHandler) Modify

func (handler *DomainWebHandler) Modify(w http.ResponseWriter, r *http.Request)

func (*DomainWebHandler) Retrieve

func (handler *DomainWebHandler) Retrieve(w http.ResponseWriter, r *http.Request)

type Error

type Error struct {
	Title   string                 `json:"title"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
}

Error structure for handler's error responses

type RBACWebHandler

type RBACWebHandler struct {
	RBACInteractor usecases.RBACInteractor
	// contains filtered or unexported fields
}

RBACWebHandler is a collection of various methods for RBAC

func NewRBACWebHandler

func NewRBACWebHandler() *RBACWebHandler

NewRBACWebHandler creates new SessionWebHandler

func (*RBACWebHandler) AssertPermission

func (handler *RBACWebHandler) AssertPermission(w http.ResponseWriter, r *http.Request)

AssertPermission checks if a current user has a specific permission

func (*RBACWebHandler) AssertRole

func (handler *RBACWebHandler) AssertRole(w http.ResponseWriter, r *http.Request)

AssertRole checks if a current user has a specific role

type SessionForm

type SessionForm struct {
	Session struct {
		User struct {
			Name     string `json:"name"`
			Password string `json:"password"`
		} `json:"user"`
		Domain struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"domain"`
	} `json:"session"`
}

SessionForm used for parsing incoming data

type SessionResource

type SessionResource struct {
	Session entities.Session `json:"session"`
}

SessionResource used for responses

type SessionWebHandler

type SessionWebHandler struct {
	SessionInteractor usecases.SessionInteractor
	UserInteractor    usecases.UserInteractor
	DomainInteractor  usecases.DomainInteractor
	// contains filtered or unexported fields
}

SessionWebHandler is a collection of CRUD methods for Sessions API

func NewSessionWebHandler

func NewSessionWebHandler() *SessionWebHandler

NewSessionWebHandler creates new SessionWebHandler

func (*SessionWebHandler) Check

func (handler *SessionWebHandler) Check(w http.ResponseWriter, r *http.Request)

Check validates if current session is valid

func (*SessionWebHandler) Create

func (handler *SessionWebHandler) Create(w http.ResponseWriter, r *http.Request)

Create opens a new session if none exists

func (*SessionWebHandler) Delete

func (handler *SessionWebHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete deletes current session

func (*SessionWebHandler) Retrieve

func (handler *SessionWebHandler) Retrieve(w http.ResponseWriter, r *http.Request)

Retrieve handles a read request of a current session

type UserWebHandler

type UserWebHandler struct {
	UserInteractor usecases.UserInteractor
}

UserWebHandler is a collection of CRUD methods for Users API

func (*UserWebHandler) Create

func (handler *UserWebHandler) Create(w http.ResponseWriter, r *http.Request)

func (*UserWebHandler) Delete

func (handler *UserWebHandler) Delete(w http.ResponseWriter, r *http.Request)

func (*UserWebHandler) List

func (handler *UserWebHandler) List(w http.ResponseWriter, r *http.Request)

func (*UserWebHandler) Modify

func (handler *UserWebHandler) Modify(w http.ResponseWriter, r *http.Request)

func (*UserWebHandler) Retrieve

func (handler *UserWebHandler) Retrieve(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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