proxy

package
v0.1.0-pre-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpHeaders

func DumpHeaders(headers map[string]spec.Header)

DumpHeaders -

func WalkOps

func WalkOps(spec *spec.Swagger, fn WalkOpsFunc)

WalkOps ... For all the paths in the spec get the operations and methods call the WalkOpsFunc (which is passed in) to process

Types

type LogReporter

type LogReporter struct {
}

LogReporter - type for "Logging" using the Reporter Interface Naming likey needs tidying a bit

func (*LogReporter) Error

func (r *LogReporter) Error(req *http.Request, err error)

Error - log error event

func (*LogReporter) Report

func (r *LogReporter) Report()

Report - generic implemetnation

func (*LogReporter) Success

func (r *LogReporter) Success(req *http.Request)

Success - log successful event

func (*LogReporter) Warning

func (r *LogReporter) Warning(req *http.Request, msg string)

Warning - log warning event

type Opts

type Opts func(*Proxy)

Opts - Proxy options

func WithAppConfig

func WithAppConfig(a *appconfig.AppConfig) Opts

WithAppConfig - option

func WithTarget

func WithTarget(target string) Opts

WithTarget - option

func WithVerbose

func WithVerbose(v bool) Opts

WithVerbose - option

type Proxy

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

Proxy defining type

func New

func New(s *spec.Swagger, reporter Reporter, opts ...Opts) (*Proxy, error)

New Proxy ceration

func (*Proxy) AppConfig

func (proxy *Proxy) AppConfig() *appconfig.AppConfig

AppConfig -

func (*Proxy) Handler

func (proxy *Proxy) Handler(next http.Handler) http.Handler

Handler -

func (*Proxy) PendingOperations

func (proxy *Proxy) PendingOperations() []*spec.Operation

PendingOperations -

func (*Proxy) Router

func (proxy *Proxy) Router() http.Handler

Router - return router

func (*Proxy) SetSpec

func (proxy *Proxy) SetSpec(spec *spec.Swagger) error

SetSpec - Marshalls the spec into a generic doc interface for the purpose of validating the spec (if it won't marshall its broken) The doc interface is useful in other scenarious within the proxy

func (*Proxy) Target

func (proxy *Proxy) Target() string

Target - return target

func (*Proxy) Validate

func (proxy *Proxy) Validate(resp Response, op *spec.Operation) error

Validate -

func (*Proxy) ValidateBody

func (proxy *Proxy) ValidateBody(resp Response, op *spec.Operation) error

ValidateBody -

func (*Proxy) ValidateHeaders

func (proxy *Proxy) ValidateHeaders(resp Response, op *spec.Operation) error

ValidateHeaders -

func (*Proxy) ValidateMIME

func (proxy *Proxy) ValidateMIME(resp Response, op *spec.Operation) error

ValidateMIME -

type Reporter

type Reporter interface {
	Success(req *http.Request)
	Error(req *http.Request, err error)
	Warning(req *http.Request, msg string)
	Report()
}

Reporter Interface - types implementing this interface can be wired to receive

type Response

type Response interface {
	Status() int
	Header() http.Header
	Body() []byte
}

Response - generic response interface

type WalkOpsFunc

type WalkOpsFunc func(path, meth string, op *spec.Operation)

WalkOpsFunc - for use with the WalkOps spec iterator Define func type to handline data structure walking

type WriterRecorder

type WriterRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

WriterRecorder - struct to access call responses

func (*WriterRecorder) Body

func (w *WriterRecorder) Body() []byte

Body - return the response body

func (*WriterRecorder) Status

func (w *WriterRecorder) Status() int

Status - returns the response status

func (*WriterRecorder) Write

func (w *WriterRecorder) Write(body []byte) (n int, err error)

Write - the body of the response

func (*WriterRecorder) WriteHeader

func (w *WriterRecorder) WriteHeader(status int)

WriteHeader - sorts out the response header status

Jump to

Keyboard shortcuts

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