proxy

package
v0.0.0-...-346f27c Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package proxy contains the implementation of the proxy used to record traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TakeSnapshot

func TakeSnapshot(
	requestID int,
	graphQLRequest GraphQLRequest,
	snapshotter Snapshotter,
	rec recorder.RecorderSaver,
	reporter Reporter,
) error

Types

type GraphQLRequest

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

	// Set after the operation is parsed
	OperationType OperationType `json:"-"`
}

func ParseRequest

func ParseRequest(content []byte) (GraphQLRequest, error)

type Handler

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

func NewHandler

func NewHandler(
	host string,
	endpoint string,
	snapshotter Snapshotter,
	rec recorder.RecorderSaver,
	selector RequestSelector,
	reporter Reporter,
	requestInfoChan chan RequestInfo,
) (*Handler, error)

func (*Handler) ProxyDirector

func (h *Handler) ProxyDirector(req *http.Request)

func (*Handler) ProxyResponseHandler

func (h *Handler) ProxyResponseHandler(resp *http.Response) error

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type OperationType

type OperationType string
const (
	OperationTypeUnknown  OperationType = "unknown"
	OperationTypeQuery    OperationType = "query"
	OperationTypeMutation OperationType = "mutation"
)

type Reporter

type Reporter interface {
	Report(label string, message string)
}

type RequestInfo

type RequestInfo struct {
	RequestID        int           `json:"requestID"`
	OperationType    OperationType `json:"operationType"`
	OperationName    string        `json:"operationName"`
	WillSnapshot     bool          `json:"willSnapshot"`
	ShapshotComplete bool          `json:"snapshotComplete"`
}

type RequestSelector

type RequestSelector interface {
	ShouldRecordRequest(r GraphQLRequest) bool
	ShouldSnapshotRequest(r GraphQLRequest) bool
}

type Snapshotter

type Snapshotter interface {
	TakeSnapshot(r GraphQLRequest) ([]byte, error)
	SnapshotInfo() string
}

Jump to

Keyboard shortcuts

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