request

package
v0.0.0-...-530fe47 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2014 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Wrapper around http.Request with additional features

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attempt

type Attempt interface {
	GetError() error
	GetDuration() time.Duration
	GetResponse() *http.Response
}

type BaseAttempt

type BaseAttempt struct {
	Error    error
	Duration time.Duration
	Response *http.Response
}

func (*BaseAttempt) GetDuration

func (ba *BaseAttempt) GetDuration() time.Duration

func (*BaseAttempt) GetError

func (ba *BaseAttempt) GetError() error

func (*BaseAttempt) GetResponse

func (ba *BaseAttempt) GetResponse() *http.Response

type BaseRequest

type BaseRequest struct {
	HttpRequest *http.Request
	ReqHeaders  http.Header
	Id          int64
	Body        []byte
	Attempts    []Attempt
	Skip        bool
	// contains filtered or unexported fields
}

func NewBaseRequest

func NewBaseRequest(r *http.Request, id int64) *BaseRequest

func (*BaseRequest) AddAttempt

func (br *BaseRequest) AddAttempt(a Attempt)

func (*BaseRequest) DeleteUserData

func (br *BaseRequest) DeleteUserData(key string)

func (*BaseRequest) GetAttempts

func (br *BaseRequest) GetAttempts() []Attempt

func (*BaseRequest) GetBody

func (br *BaseRequest) GetBody() []byte

func (*BaseRequest) GetEnvironment

func (br *BaseRequest) GetEnvironment() *models.Environment

func (*BaseRequest) GetHttpRequest

func (br *BaseRequest) GetHttpRequest() *http.Request

func (*BaseRequest) GetId

func (br *BaseRequest) GetId() int64

func (*BaseRequest) GetLastAttempt

func (br *BaseRequest) GetLastAttempt() Attempt

func (*BaseRequest) GetOrigin

func (br *BaseRequest) GetOrigin() (u *url.URL)

func (*BaseRequest) GetProject

func (br *BaseRequest) GetProject() *models.Project

Get the project first from the StopLight-Project header second from the environment if found.

func (*BaseRequest) GetUser

func (br *BaseRequest) GetUser() *models.User

Fetch and set the current user for the request

func (*BaseRequest) GetUserData

func (br *BaseRequest) GetUserData(key string) (i interface{}, b bool)

func (*BaseRequest) SetBody

func (br *BaseRequest) SetBody(b io.ReadCloser)

func (*BaseRequest) SetDb

func (br *BaseRequest) SetDb(db *gorm.DB)

func (*BaseRequest) SetHttpRequest

func (br *BaseRequest) SetHttpRequest(r *http.Request)

func (*BaseRequest) SetUserData

func (br *BaseRequest) SetUserData(key string, baton interface{})

func (*BaseRequest) String

func (br *BaseRequest) String() string

type Request

type Request interface {
	GetHttpRequest() *http.Request              // Original http request
	SetHttpRequest(*http.Request)               // Can be used to set http request
	GetId() int64                               // Request id that is unique to this running process
	SetBody(io.ReadCloser)                      // Sets request body
	GetBody() io.ReadCloser                     // Request body fully read and stored in effective manner (buffered to disk for large requests)
	AddAttempt(Attempt)                         // Add last proxy attempt to the request
	GetAttempts() []Attempt                     // Returns last attempts to proxy request, may be nil if there are no attempts
	GetLastAttempt() Attempt                    // Convenience method returning the last attempt, may be nil if there are no attempts
	String() string                             // Debugging string representation of the request
	SetUserData(key string, baton interface{})  // Provide storage space for data that survives with the request
	GetUserData(key string) (interface{}, bool) // Fetch user data set from previously SetUserData call
	DeleteUserData(key string)                  // Clean up user data set from previously SetUserData call
	SetDb() *gorm.DB                            // Set the DB for use in this request
	GetOrigin() *url.URL                        // The origin url (scheme + host + port), taking into account headers and environment
	GetProject() *models.Project                // The project id associated with this request
	GetEnvironment() *models.Environment        // The environment associated with this request
}

Request is a rapper around http request that provides more info about http.Request

Jump to

Keyboard shortcuts

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