Documentation ¶
Index ¶
- Variables
- func HandleError(rw http.ResponseWriter, err error) bool
- type AuthProvider
- type CRUDGetHandler
- type Config
- type Context
- type ContextKey
- type Core
- type DefaultHandler
- type EventSink
- type EventSinkConfig
- type HandleFunc
- type OauthConfig
- type PersistentStore
- type PersistentStoreConfig
- type StdGetHandler
- type StdListHandler
- type StdSetHandler
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("Not Found")
)
Functions ¶
func HandleError ¶
func HandleError(rw http.ResponseWriter, err error) bool
Types ¶
type AuthProvider ¶
type AuthProvider interface{}
type CRUDGetHandler ¶
type CRUDGetHandler interface {
Get(ctx *Context, rw web.ResponseWriter, req *web.Request)
}
type Config ¶
type Config struct { PersistentStore PersistentStoreConfig EventSink EventSinkConfig Oauth OauthConfig }
func ParseConfig ¶
func ParseConfig() Config
type Context ¶
type Context struct { Validators *map[reflect.Type]map[string]ValidatorFunc EventSink EventSink PersistentStore PersistentStore context.Context }
type ContextKey ¶
type ContextKey string
const (
PersistentStoreKey ContextKey = "CRUDPersistentStore"
)
type Core ¶
type Core struct { Validators map[reflect.Type]map[string]ValidatorFunc Resources map[string]interface{} Router *web.Router EventSink EventSink PersistentStore PersistentStore OauthProvider AuthProvider Config Config }
func New ¶
New will return a new Core object with the config parsed and EventSink, PersistentStore, Oauth Provider
func (*Core) RegisterPersistentStore ¶
func (core *Core) RegisterPersistentStore(ps PersistentStore) error
func (*Core) RegisterResource ¶
func (core *Core) RegisterResource(res interface{})
func (*Core) RegisterValidator ¶
func (core *Core) RegisterValidator(name string, validator ValidatorFunc)
type DefaultHandler ¶
type DefaultHandler struct {
// contains filtered or unexported fields
}
type EventSinkConfig ¶
type HandleFunc ¶
type HandleFunc func(ctx *Context, rw web.ResponseWriter, req *web.Request)
type OauthConfig ¶
type PersistentStore ¶
type PersistentStore interface { // Connect will use the provided config to connect to the persistent store provider Connect(PersistentStoreConfig) error // Session will be called before handling each request. It should return a new PersistentStore with the object that should be used for querying properly initialised. This is present to support connection pooling, but is not required to be used. If session returns nil then the original PersistentStore will be used Session() PersistentStore // Get returns the object identified by the given key from the table with the supplied name, and saves the result into the supplied dst object pointer Get(key interface{}, tableName string, dst interface{}) error // List returns a list of objects filtered using key:value pairs. The interface passed into List will always be a pointer to a slice of the reource to be listed List(tableName string, filters map[string]interface{}, dst interface{}) error // Insert will create a new entry using the provided key and value and will return an error if the operation has failed. Insert(key interface{}, tableName string, value interface{}) error // Insert will create a new entry using the provided key and value and overwrite the existing value if it does exist, and will return an error if the operation has failed. Set(key interface{}, tableName string, value interface{}) error // Update will provide partial modification of objects in a json-patch style update (TBD) Update(key interface{}, tableName string, value interface{}) error // Delete will remove the entry associated with the provided key Delete(key interface{}, tableName string) error // Close will close the underlying connection Close() error // Raw will return a pointer to the underlying db connection Raw() interface{} }
func ExtractPersistentStore ¶
func ExtractPersistentStore(ctx context.Context) PersistentStore
type PersistentStoreConfig ¶
type StdGetHandler ¶
type StdGetHandler interface {
Get(rw http.ResponseWriter, req *http.Request)
}
type StdListHandler ¶
type StdListHandler interface {
List(rw http.ResponseWriter, req *http.Request)
}
type StdSetHandler ¶
type StdSetHandler interface {
Set(rw http.ResponseWriter, req *http.Request)
}
type ValidatorFunc ¶
ValidatorFunc describes the format for validator functions. The annotation used to call the validator is provided to enable implementing variations within the same validator (eg: dates)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.