servers

package
v0.0.0-...-764bd47 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ORDER_ARG = "order"
View Source
const USE_OBJECT_CACHE = true

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c schema.Context, w http.ResponseWriter, title string, detail string)

func DetailHandler

func DetailHandler(s schema.Server, m *schema.Model, w http.ResponseWriter, r *http.Request)

func Forbidden

func Forbidden(c schema.Context, w http.ResponseWriter, title string, detail string)

func GetIntParam

func GetIntParam(
	params map[string][]string,
	key string,
	name string,
	defaultVal int,
	min *int,
	max *int,
) (int, error)

func GetStringParam

func GetStringParam(
	params map[string][]string,
	key string,
	name string,
	defaultVal string,
) (string, error)

func InternalServerError

func InternalServerError(c schema.Context, w http.ResponseWriter)

func ListHandler

func ListHandler(s schema.Server, m *schema.Model, w http.ResponseWriter, r *http.Request)

func MethodNotAllowed

func MethodNotAllowed(c schema.Context, w http.ResponseWriter)

func NotFound

func NotFound(c schema.Context, w http.ResponseWriter, model string, id string)

func ParameterInfoHandler

func ParameterInfoHandler(
	s schema.Server,
	m *schema.Model,
	w http.ResponseWriter,
	r *http.Request,
)

func RelationHandler

func RelationHandler(
	s schema.Server,
	m *schema.Model,
	relationship schema.Relationship,
	w http.ResponseWriter,
	r *http.Request,
)

func UniqueInstances

func UniqueInstances(set []schema.Instance) []schema.Instance

Types

type CachedInstance

type CachedInstance struct {
	Instance    schema.Instance
	RelationMap map[string]map[string][]string
}

type ContextTransaction

type ContextTransaction struct {
	// contains filtered or unexported fields
}

func (*ContextTransaction) Commit

func (t *ContextTransaction) Commit() error

func (*ContextTransaction) Exec

func (t *ContextTransaction) Exec(query string, args ...interface{}) (sql.Result, error)

func (*ContextTransaction) Query

func (t *ContextTransaction) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*ContextTransaction) QueryRow

func (t *ContextTransaction) QueryRow(query string, args ...interface{}) *sql.Row

func (*ContextTransaction) Rollback

func (t *ContextTransaction) Rollback() error

type Error

type Error struct {
	Exceptions []Exception `json:"errors"`
}

type Exception

type Exception struct {
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

type IncludeResult

type IncludeResult struct {
	Instances []schema.Instance
	Included  []schema.Instance
	Error     error
}

type RelationResult

type RelationResult struct {
	Key          string
	Index        int
	Default      interface{}
	Values       map[string]interface{}
	RelationMaps map[string]map[string][]string
}

type RequestContext

type RequestContext struct {
	Server         schema.Server
	Request        *http.Request
	ResponseWriter http.ResponseWriter

	InstanceCache struct {
		sync.Mutex
		Instances map[string]map[string]CachedInstance
	}
	// contains filtered or unexported fields
}

func (*RequestContext) Authenticate

func (rc *RequestContext) Authenticate() error

func (*RequestContext) Begin

func (rc *RequestContext) Begin() (schema.Transaction, error)

func (*RequestContext) CacheObject

func (rc *RequestContext) CacheObject(object schema.Instance, relationMap map[string]map[string][]string)

func (*RequestContext) CanAccessAllInstances

func (rc *RequestContext) CanAccessAllInstances(instances []schema.Instance) bool

func (*RequestContext) Exec

func (rc *RequestContext) Exec(query string, args ...interface{}) (sql.Result, error)

func (*RequestContext) FlushCache

func (rc *RequestContext) FlushCache()

func (*RequestContext) GetCachedObject

func (rc *RequestContext) GetCachedObject(instanceType string, instanceId string) (schema.Instance, map[string]map[string][]string)

func (*RequestContext) GetObjectsByFilter

func (rc *RequestContext) GetObjectsByFilter(
	m *schema.Model,
	whereQueries []string,
	whereArgs []interface{},
	orderQuery string,
	offset int,
	limit int,
	include *schema.Include,
) (
	[]schema.Instance,
	[]schema.Instance,
	error,
)

func (*RequestContext) GetObjectsByIDs

func (rc *RequestContext) GetObjectsByIDs(
	m *schema.Model,
	objectIds []string,
	include *schema.Include,
) (
	[]schema.Instance,
	[]schema.Instance,
	error,
)

func (*RequestContext) GetObjectsByIDsAllRelations

func (rc *RequestContext) GetObjectsByIDsAllRelations(
	m *schema.Model,
	objectIds []string,
	include *schema.Include,
) (
	[]schema.Instance,
	[]schema.Instance,
	error,
)

func (*RequestContext) GetQueryCount

func (rc *RequestContext) GetQueryCount() int

func (*RequestContext) GetRequest

func (rc *RequestContext) GetRequest() *http.Request

func (*RequestContext) GetServer

func (rc *RequestContext) GetServer() schema.Server

func (*RequestContext) GetUser

func (rc *RequestContext) GetUser() schema.User

func (*RequestContext) IncrementQueryCount

func (rc *RequestContext) IncrementQueryCount()

func (*RequestContext) InitCache

func (rc *RequestContext) InitCache()

func (*RequestContext) LogQuery

func (rc *RequestContext) LogQuery(query string)

func (*RequestContext) LogStats

func (rc *RequestContext) LogStats()

func (*RequestContext) Query

func (rc *RequestContext) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*RequestContext) QueryRow

func (rc *RequestContext) QueryRow(query string, args ...interface{}) *sql.Row

func (*RequestContext) SetUser

func (rc *RequestContext) SetUser(user schema.User)

func (*RequestContext) WriteToResponse

func (rc *RequestContext) WriteToResponse(blob interface{})

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(db schema.Database, auth schema.Authenticator) *Server

func (*Server) Authenticate

func (s *Server) Authenticate(w http.ResponseWriter, r *http.Request, rc schema.Context) (schema.User, error)

func (*Server) DisableEasyJSON

func (s *Server) DisableEasyJSON()

func (*Server) DisableSQLLogging

func (s *Server) DisableSQLLogging()

func (*Server) DisableWhitespace

func (s *Server) DisableWhitespace()

func (*Server) EnableEasyJSON

func (s *Server) EnableEasyJSON()

func (*Server) EnableSQLLogging

func (s *Server) EnableSQLLogging()

func (*Server) EnableWhitespace

func (s *Server) EnableWhitespace()

func (*Server) GetDatabase

func (s *Server) GetDatabase() schema.Database

func (*Server) GetDefaultDirectPageSize

func (s *Server) GetDefaultDirectPageSize() int

func (*Server) GetIndirectPageSize

func (s *Server) GetIndirectPageSize() int

func (*Server) GetMaximumDirectPageSize

func (s *Server) GetMaximumDirectPageSize() int

func (*Server) GetModel

func (s *Server) GetModel(modelType string) *schema.Model

func (*Server) GetRoute

func (s *Server) GetRoute(modelType string) string

func (*Server) Handle

func (s *Server) Handle(router *mux.Router, modelType string, path string)

func (*Server) LogSQL

func (s *Server) LogSQL() bool

func (*Server) RegisterModel

func (s *Server) RegisterModel(model *schema.Model)

func (*Server) SetDefaultDirectPageSize

func (s *Server) SetDefaultDirectPageSize(size int)

func (*Server) SetIndirectPageSize

func (s *Server) SetIndirectPageSize(size int)

func (*Server) SetMaximumDirectPageSize

func (s *Server) SetMaximumDirectPageSize(size int)

func (*Server) UseEasyJSON

func (s *Server) UseEasyJSON() bool

func (*Server) Whitespace

func (s *Server) Whitespace() bool

Jump to

Keyboard shortcuts

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