Documentation ¶
Index ¶
Constants ¶
const ( DEFAULT_KEYWORD = "default" YAML_REGEX = "^\\w*\\.(yaml|yml|YAML|YML)*$" )
const ( ETAG_SERVER_HEADER = "ETag" HTTP_LOCATION_HEADER = "Location" HTTP_CODE_BOUNDARY = 400 HTTP_CODE_REDIRECT = 300 )
Variables ¶
var ( ErrUnknown = errors.New("E001") ErrNotFound = errors.New("E002") ErrNoContent = errors.New("E003") )
var (
DefaultTimeout = 10 * time.Minute
)
Functions ¶
func DigestRequest ¶
DigestRequest returns the md5 of the given request rq taking as input parameters the request's method, the exact host and path, all those listed query params and headers, and the body, if any
func FormatHttpRequest ¶
FormatHttpRequest returns and string descriving the content of an HttpRequest
Types ¶
type Cache ¶
type Cache interface { Store(string, interface{}, time.Duration) error Load(string, interface{}) error }
A Cache represents an storage for request's responses
type ConfigFile ¶
type ConfigGroup ¶
type ConfigGroup struct {
// contains filtered or unexported fields
}
ConfigGroup represents a set of settings to apply over http requests and responses
func NewConfigGroup ¶
func NewConfigGroup(path string, logger *zap.Logger) (*ConfigGroup, error)
NewConfigGroup reads the content of the provided path and returns the declared configuration
func (*ConfigGroup) AddConfig ¶
func (group *ConfigGroup) AddConfig(file *ConfigFile) (err error)
AddConfig registers the given configuration into the config group
func (*ConfigGroup) ReadDir ¶
func (group *ConfigGroup) ReadDir(dir string) error
ReadDir applies all configuration files inside the given directory into the current configuration
func (*ConfigGroup) ReadFile ¶
func (group *ConfigGroup) ReadFile(filepath string) error
ReadFile applies a configuration file into the current configuration
func (*ConfigGroup) RequestOptions ¶
func (group *ConfigGroup) RequestOptions(endpoint string, method string) (*Options, bool)
RequestOptions returns the Options instance for the given endpoint and method
type HttpResponse ¶
func NewHttpResponse ¶
func NewHttpResponse() *HttpResponse
func (*HttpResponse) Echo ¶
func (r *HttpResponse) Echo(w http.ResponseWriter) (int, error)
func (*HttpResponse) Empty ¶
func (r *HttpResponse) Empty() bool
func (*HttpResponse) Format ¶
func (r *HttpResponse) Format() (format string)
func (*HttpResponse) Header ¶
func (r *HttpResponse) Header() http.Header
implement http.ResponseWriter https://golang.org/pkg/net/http/#ResponseWriter
func (*HttpResponse) WriteHeader ¶
func (r *HttpResponse) WriteHeader(i int)
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func NewOptions ¶
func NewOptions() *Options
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶
NewRedisCache returns an implementation of Cache for RedisCache
type ReverseProxy ¶
type ReverseProxy struct { DigestRequest func(req *http.Request) (string, error) // contains filtered or unexported fields }
A ReverseProxy is a cached reverse proxy that captures responses in order to provide it in the future instead of permorming the same request each time
func NewReverseProxy ¶
func NewReverseProxy(manager Config, cache Cache, logger *zap.Logger) *ReverseProxy
NewReverseProxy returns a brand new ReverseProxy with the provided config and cache
func (*ReverseProxy) ServeHTTP ¶
func (reverse *ReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP performs http requests if not cached yet or returns the chaced body instead