Documentation ¶
Index ¶
- func GateLoggedIn(ctx *Ctx) bool
- func GatePublic(*Ctx) bool
- func HashPassword(pw string) string
- func KernelDeleteRelationships(ctx *Ctx) error
- func KernelDeleteResource(ctx *Ctx) error
- func KernelGetCollection(ctx *Ctx) error
- func KernelGetRelationship(ctx *Ctx) error
- func KernelGetRelationships(ctx *Ctx) error
- func KernelGetResource(ctx *Ctx) error
- func KernelInsertRelationships(ctx *Ctx) error
- func KernelInsertResource(ctx *Ctx) error
- func KernelUpdateRelationship(ctx *Ctx) error
- func KernelUpdateRelationships(ctx *Ctx) error
- func KernelUpdateResource(ctx *Ctx) error
- func RandomID(length int) string
- func TableName(rel jsonapi.Rel) string
- func TerminateCmd(app *App) error
- type App
- func (a *App) Debug(msg string, args ...interface{})
- func (a *App) Delete(route string, k Kernel, g ...Gate)
- func (a *App) Get(route string, k Kernel, g ...Gate)
- func (a *App) Info(msg string, args ...interface{})
- func (a *App) Post(route string, k Kernel, g ...Gate)
- func (a *App) Put(route string, k Kernel, g ...Gate)
- func (a *App) ReadConfig(data []byte) error
- func (a *App) Run() error
- func (a *App) RunCLI()
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) Shutdown() error
- type Config
- type Ctx
- type Gate
- type Kernel
- type Key
- type Query
- type ResponseWriter
- type Store
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KernelDeleteRelationships ¶
KernelDeleteRelationships ...
func KernelGetRelationships ¶
KernelGetRelationships ...
func KernelInsertRelationships ¶
KernelInsertRelationships ...
func KernelUpdateRelationship ¶
KernelUpdateRelationship ...
func KernelUpdateRelationships ¶
KernelUpdateRelationships ...
Types ¶
type App ¶
type App struct { sync.Mutex Config Config Store Store `json:"-"` CLI *cli.App `json:"-"` Server http.Server `json:"-"` *jsonapi.Registry Kernels map[string]Kernel `json:"-"` Gates map[string][]Gate `json:"-"` }
An App represents the instance of an application that listens and responds to HTTP requests.
type Config ¶
type Config struct { Name string PrePath string Port uint16 Debug bool Info bool Minimize bool Store struct { Driver string Host string Database string User string Password string Options map[string]string } }
Config ...
type Ctx ¶
type Ctx struct { sync.Mutex `json:"-"` App *App `json:"-"` Tx Tx // Log Log []string // Request W ResponseWriter `json:"-"` Method string URL *jsonapi.URL // User JWT *jwt.Token `json:"-"` ID string Groups []string // Payloads In *jsonapi.Payload Out *jsonapi.Document }
A Ctx is passed around during a request for storing temporary data related to the request.
func NewCtx ¶
func NewCtx(a *App, w ResponseWriter, r *http.Request) *Ctx
NewCtx creates a Ctx and returns it.
type Query ¶
type Query struct { Type string ID string Fields []string BelongsToFilter jsonapi.BelongsToFilter Filter *jsonapi.Condition Sort []string PageSize int PageNumber int }
Query represents a resource or a collection.
To get a resource, only Type and ID are used. To get a collection, all fields except ID are considered.
Filter is not necessary. Fields will default to a slice containing the string "id" if nil or empty.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter // Status returns the HTTP status of the response, or 0 if it hasn't been // set yet. Status() int // Written returns wether a status code has been written or not. Written() bool // Unwrap returns the original proxied target. Unwrap() http.ResponseWriter }
ResponseWriter is a wrapper around http.ResponseWriter that provides extra methods about the response.
func WrapResponseWriter ¶
func WrapResponseWriter(w http.ResponseWriter) ResponseWriter
WrapResponseWriter wraps an http.ResponseWriter and returns a ResponseWriter.
type Store ¶
type Store interface { // Connection management Open(driver, host, db, user, pw string, opts map[string]string) error URL() string Close() // Transaction Begin() (Tx, error) // Resource manipulation SelectCollection(tx Tx, resType string, from jsonapi.BelongsToFilter, params *jsonapi.Params, c jsonapi.Collection) error SelectResource(tx Tx, resType, resID string, from jsonapi.BelongsToFilter, params *jsonapi.Params, r jsonapi.Resource) error SelectInclusions(tx Tx, originType, originID string, from jsonapi.BelongsToFilter, params *jsonapi.Params) ([]jsonapi.Resource, error) InsertResource(tx Tx, r jsonapi.Resource) error UpdateResource(tx Tx, resType, resID string, updates map[string]interface{}) error DeleteResource(tx Tx, resType, resID string) error ResourceExists(tx Tx, resType, resID string) (bool, error) // Relationship manipulation SelectRelationship(tx Tx, resType, resID, relName string) (string, error) SelectRelationships(tx Tx, resType, resID, relName string) ([]string, error) UpdateRelationship(tx Tx, resType, resID, relName, relID string) error UpdateRelationships(tx Tx, resType, resID, relName string, relIDs []string) error InsertRelationships(tx Tx, resType, resID, relName string, relIDs []string) error DeleteRelationship(tx Tx, resType, resID, relID, relName string) error DeleteRelationships(tx Tx, resType, resID, relName string, relIDs []string) error DeleteAllRelationships(tx Tx, resType, resID, relName string) error // Other CountCollectionSize(tx Tx, resType string, from jsonapi.BelongsToFilter, params *jsonapi.Params) (int, error) // Database management SetRegistry(reg *jsonapi.Registry) SelectResourceTables(tx Tx) ([]string, error) SelectRelationshipTables(tx Tx) ([]string, error) SelectColumns(tx Tx, resType string) ([]map[string]string, error) CreateResourceTable(tx Tx, typ jsonapi.Type) error CreateRelationshipTable(tx Tx, rel jsonapi.Rel) error AddColumn(tx Tx, resType string, attr jsonapi.Attr) error DropTable(tx Tx, resType string) error DropColumn(tx Tx, resType, colName string) error DrainDatabase(tx Tx) error SyncDatabase(tx Tx, reg *jsonapi.Registry, verbose, apply bool) error }
Store ...