rcap

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestFieldTypeMeta   = int32(0)
	RequestFieldTypeBody   = int32(1)
	RequestFieldTypeHeader = int32(2)
	RequestFieldTypeParams = int32(3)
	RequestFieldTypeState  = int32(4)
)

Variables

View Source
var (
	ErrReqNotSet        = errors.New("req is not set")
	ErrInvalidFieldType = errors.New("invalid field type")
	ErrInvalidKey       = errors.New("invalid key")
)
View Source
var ErrCacheKeyNotFound = errors.New("key not found")

ErrCacheKeyNotFound is returned when a non-existent cache key is requested

View Source
var (
	ErrFileFuncNotSet = errors.New("file func not set")
)

Functions

This section is empty.

Types

type AuthHeader

type AuthHeader struct {
	HeaderType string `json:"headerType"`
	Value      string `json:"value"`
}

AuthHeader is an HTTP header designed to authenticate requests

type AuthProvider

type AuthProvider interface {
	HeaderForDomain(string) *AuthHeader
}

AuthProvider is a provider for various kinds of auth

func DefaultAuthProvider

func DefaultAuthProvider(config *AuthProviderConfig) AuthProvider

DefaultAuthProvider creates the default static auth provider

type AuthProviderConfig

type AuthProviderConfig struct {
	// Headers is a map between domains and auth header that should be added to requests to those domains
	Headers map[string]AuthHeader `json:"headers"`
}

AuthProviderConfig is a config for the default auth provider

type Cache

type Cache interface {
	Set(key string, val []byte, ttl int) error
	Get(key string) ([]byte, error)
	Delete(key string) error
}

Cache gives Runnables access to a key/value cache

func DefaultCache

func DefaultCache() Cache

type FileSource

type FileSource interface {
	GetStatic(filename string) ([]byte, error)
}

FileSource gives runnables access to various kinds of files

func DefaultFileSource

func DefaultFileSource(staticFileFunc StaticFileFunc) FileSource

type GraphQLClient

type GraphQLClient interface {
	Do(auth AuthProvider, endpoint, query string) (*GraphQLResponse, error)
}

GraphQLClient is a GraphQL capability for Reactr Modules

func DefaultGraphQLClient

func DefaultGraphQLClient() GraphQLClient

DefaultGraphQLClient creates a GraphQLClient object

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
	Path    string `json:"path"`
}

GraphQLError is a GraphQL error

type GraphQLRequest

type GraphQLRequest struct {
	Query         string            `json:"query"`
	Variables     map[string]string `json:"variables,omitempty"`
	OperationName string            `json:"operationName,omitempty"`
}

GraphQLRequest is a request to a GraphQL endpoint

type GraphQLResponse

type GraphQLResponse struct {
	Data   map[string]interface{} `json:"data"`
	Errors []GraphQLError         `json:"errors,omitempty"`
}

GraphQLResponse is a GraphQL response

type HTTPClient

type HTTPClient interface {
	Do(auth AuthProvider, method, urlString string, body []byte, headers http.Header) (*http.Response, error)
}

HTTPClient gives Runnables the ability to make HTTP requests

func DefaultHTTPClient

func DefaultHTTPClient() HTTPClient

DefaultHTTPClient creates an HTTP client with no restrictions

type LoggerSource

type LoggerSource interface {
	Logger() *vlog.Logger
}

LoggerSource provides a logger to Runnables

func DefaultLoggerSource

func DefaultLoggerSource(logger *vlog.Logger) LoggerSource

DefaultLoggerSource returns a LoggerSource that provides vlog.Default

type RequestHandler

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

RequestHandler allows runnables to handle HTTP requests

func NewRequestHandler

func NewRequestHandler(req *request.CoordinatedRequest) *RequestHandler

NewRequestHandler provides a handler for the given request

func (RequestHandler) GetField

func (r RequestHandler) GetField(fieldType int32, key string) ([]byte, error)

func (RequestHandler) SetResponseHeader

func (r RequestHandler) SetResponseHeader(key, val string) error

SetResponseHeader sets a header on the response

type StaticFileFunc

type StaticFileFunc func(string) ([]byte, error)

StaticFileFunc is a function that returns the contents of a requested file

Jump to

Keyboard shortcuts

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