Versions in this module Expand all Collapse all v0 v0.15.2 Oct 5, 2022 Changes in this version + const DBTypeMySQL + const DBTypePostgres + const RequestFieldTypeBody + const RequestFieldTypeHeader + const RequestFieldTypeMeta + const RequestFieldTypeParams + const RequestFieldTypeQuery + const RequestFieldTypeState + var ErrCacheKeyNotFound = errors.New("key not found") + var ErrCapabilityNotAvailable = errors.New("capability not available") + var ErrCapabilityNotEnabled = errors.New("capability is not enabled") + var ErrDatabaseTypeInvalid = errors.New("database type invalid") + var ErrDomainDisallowed = errors.New("requests to this domain are disallowed") + var ErrHttpDisallowed = errors.New("requests to insecure HTTP endpoints is disallowed") + var ErrIPsDisallowed = errors.New("requests to IP addresses are disallowed") + var ErrInvalidFieldType = errors.New("invalid field type") + var ErrKeyNotFound = errors.New("key not found") + var ErrPortDisallowed = errors.New("requests to this port are disallowed") + var ErrPrivateDisallowed = errors.New("requests to private IP address ranges are disallowed") + var ErrQueryNotFound = errors.New("query not found") + var ErrQueryNotPrepared = errors.New("query not prepared") + var ErrQueryTypeInvalid = errors.New("query type invalid") + var ErrQueryTypeMismatch = errors.New("query type incorrect") + var ErrQueryVarsMismatch = errors.New("number of variables incorrect") + var ErrReqNotSet = errors.New("req is not set") + func AugmentedValFromEnv(original string) string + type AuthCapability interface + HeaderForDomain func(string) *AuthHeader + func DefaultAuthProvider(config AuthConfig) AuthCapability + type AuthConfig struct + Enabled bool + Headers map[string]AuthHeader + type AuthHeader struct + HeaderType string + Value string + type CacheCapability interface + Delete func(key string) error + Get func(key string) ([]byte, error) + Set func(key string, val []byte, ttl int) error + func SetupCache(config CacheConfig) CacheCapability + type CacheConfig struct + Enabled bool + RedisConfig *RedisConfig + Rules CacheRules + type CacheRules struct + AllowDelete bool + AllowGet bool + AllowSet bool + type Capabilities struct + Auth AuthCapability + Cache CacheCapability + Database DatabaseCapability + FileSource FileCapability + GraphQLClient GraphQLCapability + HTTPClient HTTPCapability + LoggerSource LoggerCapability + RequestConfig *RequestHandlerConfig + func New(logger *vlog.Logger) *Capabilities + func NewWithConfig(config CapabilityConfig) (*Capabilities, error) + func (c Capabilities) Config() CapabilityConfig + type CapabilityConfig struct + Auth *AuthConfig + Cache *CacheConfig + DB *DatabaseConfig + File *FileConfig + GraphQL *GraphQLConfig + HTTP *HTTPConfig + Logger *LoggerConfig + Request *RequestHandlerConfig + func DefaultCapabilityConfig() CapabilityConfig + func DefaultConfigWithDB(logger *vlog.Logger, dbType, dbConnString string, queries []Query) CapabilityConfig + func DefaultConfigWithLogger(logger *vlog.Logger) CapabilityConfig + func NewConfig(logger *vlog.Logger, dbType, dbConnString string, queries []Query) CapabilityConfig + type DatabaseCapability interface + ExecQuery func(queryType int32, name string, vars []interface{}) ([]byte, error) + Prepare func(q *Query) error + func NewSqlDatabase(config *DatabaseConfig) (DatabaseCapability, error) + type DatabaseConfig struct + ConnectionString string + DBType string + Enabled bool + Queries []Query + type FileCapability interface + GetStatic func(filename string) ([]byte, error) + func DefaultFileSource(config FileConfig) FileCapability + type FileConfig struct + Enabled bool + FileFunc StaticFileFunc + type GraphQLCapability interface + Do func(auth AuthCapability, endpoint, query string) (*GraphQLResponse, error) + func DefaultGraphQLClient(config GraphQLConfig) GraphQLCapability + type GraphQLConfig struct + Enabled bool + Rules HTTPRules + type GraphQLError struct + Message string + Path string + type GraphQLRequest struct + OperationName string + Query string + Variables map[string]string + type GraphQLResponse struct + Data map[string]interface{} + Errors []GraphQLError + type HTTPCapability interface + Do func(auth AuthCapability, method, urlString string, body []byte, ...) (*http.Response, error) + func DefaultHTTPClient(config HTTPConfig) HTTPCapability + type HTTPConfig struct + Enabled bool + Rules HTTPRules + type HTTPRules struct + AllowHTTP bool + AllowIPs bool + AllowPrivate bool + AllowedDomains []string + AllowedPorts []int + BlockedDomains []string + BlockedPorts []int + type LoggerCapability interface + Log func(level int32, msg string, scope interface{}) + func DefaultLoggerSource(config LoggerConfig) LoggerCapability + type LoggerConfig struct + Enabled bool + Logger *vlog.Logger + type Query struct + Name string + Query string + Type QueryType + VarCount int + type QueryType int32 + const QueryTypeDelete + const QueryTypeInsert + const QueryTypeSelect + const QueryTypeUpdate + type RedisCache struct + func (r *RedisCache) Delete(key string) error + func (r *RedisCache) Get(key string) ([]byte, error) + func (r *RedisCache) Set(key string, val []byte, ttl int) error + type RedisConfig struct + Password string + ServerAddress string + Username string + type RequestHandlerCapability interface + GetField func(fieldType int32, key string) ([]byte, error) + SetField func(fieldType int32, key string, val string) error + SetResponseHeader func(key, val string) error + func NewRequestHandler(config RequestHandlerConfig, req *request.CoordinatedRequest) RequestHandlerCapability + type RequestHandlerConfig struct + AllowGetField bool + AllowSetField bool + Enabled bool + type SqlDatabase struct + func (s *SqlDatabase) ExecQuery(queryType int32, name string, vars []interface{}) ([]byte, error) + func (s *SqlDatabase) Prepare(q *Query) error + type StaticFileFunc func(string) ([]byte, error)