Documentation ¶
Index ¶
- func GetAllowedMethods() []string
- func New(rester Rester) http.Handler
- type AllGetter
- type Builder
- func (b *Builder) AddCreate(h Creator) *Builder
- func (b *Builder) AddDelete(h Deleter) *Builder
- func (b *Builder) AddGetAll(handler AllGetter) *Builder
- func (b *Builder) AddGetSingle(handler SingleGetter) *Builder
- func (b *Builder) AddIndex(h SingleIndexer) *Builder
- func (b *Builder) AddOptions() *Builder
- func (b *Builder) AddPatch(h Patcher) *Builder
- func (b *Builder) AddUpdate(h Updater) *Builder
- func (b *Builder) Build() *mux.Router
- type Creator
- type Deleter
- type Patcher
- type ResponseContentTypeSetter
- type ResponseEncoder
- type Rester
- type ResterError
- type SingleGetter
- type SingleIndexer
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllowedMethods ¶
func GetAllowedMethods() []string
GetAllowedMethods returns all allowed http methods used by REST. Useful to populate wrapping handlers (eg. CORS handler).
Types ¶
type AllGetter ¶
type AllGetter interface {
GetAll() (interface{}, error)
}
AllGetter defines the interface to get all resources
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder holds data and methods to create a new REST flavored Router
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder creates a new Builder. ResourcePath defines the uri-path for the resource.
func (*Builder) AddCreate ¶
AddCreate adds a route entry and connects it with the given Creator implementation
func (*Builder) AddDelete ¶
AddDelete adds a route entry and connects it with the given Deleter implementation
func (*Builder) AddGetAll ¶
AddGetAll adds a route entry and connects it with the given AllGetter implementation
func (*Builder) AddGetSingle ¶
func (b *Builder) AddGetSingle(handler SingleGetter) *Builder
AddGetSingle adds a route entry and connects it with the given SingleGetter implementation
func (*Builder) AddIndex ¶
func (b *Builder) AddIndex(h SingleIndexer) *Builder
AddIndex adds a route entry and connects it with the given SingleIndexer implementation
func (*Builder) AddOptions ¶
AddOptions adds a route entry to handle OPTIONS requests
func (*Builder) AddPatch ¶
AddPatch adds a route entry and connects it with the given Patcher implementation
type ResponseContentTypeSetter ¶
ResponseContentTypeSetter can be used to set the response content-type. If the first return value of a Rester function returns implements this interface it can define the content-type that is passed to the client
type ResponseEncoder ¶
type ResponseEncoder interface {
Encode(contentType string) interface{}
}
ResponseEncoder can be used to implement custom response content encoding. If the first return value of a Rester function returns implements this interface the Encode function will be called and the result will be passed back to the client.
type Rester ¶
type Rester interface { SingleGetter AllGetter SingleIndexer Creator Patcher Deleter Updater }
Rester defines an full feature interface that is called per REST action
type ResterError ¶
ResterError defines an interface that enables Rester implementations to pass back custom HTTP Status Codes to express custom error values. If an error from a Rester function implements this interface its status code will be passed back to the client.
type SingleGetter ¶
SingleGetter defines the interface to get a single resource
type SingleIndexer ¶
SingleIndexer defines the interface to get the index of a single resource