Documentation
¶
Index ¶
- func HandleRequest(controller DestroyableController, rs Response) error
- func SetRegisterer(registerer Registerer)
- type Controller
- type ControllerDestroyer
- type ControllerFactoryFunc
- type DestroyableController
- type Handler
- type MessageResponse
- type NullDestroyer
- type NullRegisterer
- func (NullRegisterer) DELETE(prefix string, path string, handler Handler)
- func (NullRegisterer) GET(prefix string, path string, handler Handler)
- func (NullRegisterer) PATCH(prefix string, path string, handler Handler)
- func (NullRegisterer) POST(prefix string, path string, handler Handler)
- func (NullRegisterer) PUT(prefix string, path string, handler Handler)
- type Registerer
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleRequest ¶
func HandleRequest(controller DestroyableController, rs Response) error
HandleRequest handle API request using Controller produced by ControllerFactory and sets response status to BadRequest with error message, if controller returns ValidationError
func SetRegisterer ¶
func SetRegisterer(registerer Registerer)
Types ¶
type Controller ¶
type Controller interface {
Run() error
}
Controller represents ability to call business logic from request handling method
type ControllerDestroyer ¶
type ControllerDestroyer interface {
Destroy() error
}
ControllerDestroyer function to be called when controller is no longer needed during request
type ControllerFactoryFunc ¶
type ControllerFactoryFunc func(Request, Response) (Controller, ControllerDestroyer, error)
ControllerFactoryFunc function to be called when controller is no longer needed during request
type DestroyableController ¶
type DestroyableController struct {
C Controller
Cd ControllerDestroyer
}
DestroyableController wrapper to handle controller destruction after usage
func (DestroyableController) Destroy ¶
func (d DestroyableController) Destroy() error
func (DestroyableController) Run ¶
func (d DestroyableController) Run() error
type MessageResponse ¶
type MessageResponse struct {
Message string `json:"message"`
}
MessageResponse represents JSON message response body
func Message ¶
func Message(err error) MessageResponse
Message returns new message response body, based on error message
type NullDestroyer ¶
type NullDestroyer struct {
}
func (NullDestroyer) Destroy ¶
func (NullDestroyer) Destroy() error
type NullRegisterer ¶
type NullRegisterer struct {
}
func (NullRegisterer) DELETE ¶
func (NullRegisterer) DELETE(prefix string, path string, handler Handler)
func (NullRegisterer) PATCH ¶
func (NullRegisterer) PATCH(prefix string, path string, handler Handler)
type Registerer ¶
type Registerer interface {
GET(prefix string, path string, handler Handler)
PATCH(prefix string, path string, handler Handler)
POST(prefix string, path string, handler Handler)
PUT(prefix string, path string, handler Handler)
DELETE(prefix string, path string, handler Handler)
}
Registerer represents ability to register methods in http API
func GetRegisterer ¶
func GetRegisterer() Registerer