simulator

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestExtension        = ".request"
	ResponseExtension       = ".response"
	ResponseHeaderExtension = ".response_headers"
	RequestBodyExtension    = ".request_body"
	SimulationConfig        = "simulation_config.json"
	RecordingRoot           = "gateway/testdata/recordings"
)
View Source
const EtagExtension = "etag"

Variables

View Source
var PlaybackParams struct {
	IsPlayback                bool
	CurrentUploadID           []byte // used at playback to set the upload id in
	RecordingDir, PlaybackDir string
}

Functions

func NewExternalRecordDownloader

func NewExternalRecordDownloader(region string) *externalRecordDownloader

func RegisterRecorder

func RegisterRecorder(next http.Handler, authService GatewayAuthService, region string, bareDomains []string) http.Handler

func ShutdownRecorder

func ShutdownRecorder()

Types

type GatewayAuthService

type GatewayAuthService interface {
	GetCredentials(ctx context.Context, accessKey string) (*model.Credential, error)
	GetUserByID(ctx context.Context, userID int) (*model.User, error)
	Authorize(ctx context.Context, req *auth.AuthorizationRequest) (*auth.AuthorizationResponse, error)
}

a limited service interface for the gateway, used by simulation playback

type LazyOutput

type LazyOutput struct {
	Name   string
	F      *os.File
	IsOpen bool
}

func NewLazyOutput

func NewLazyOutput(name string) *LazyOutput

func (*LazyOutput) Close

func (l *LazyOutput) Close() error

func (*LazyOutput) Write

func (l *LazyOutput) Write(d []byte) (int, error)

type PlayBackMockConf

type PlayBackMockConf struct {
	BareDomain      string `json:"bare_domain"`
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"access_secret_key"`
	UserID          int    `json:"user_id"`
	Region          string `json:"region"`
}

func (*PlayBackMockConf) Authorize

func (*PlayBackMockConf) GetCredentials

func (m *PlayBackMockConf) GetCredentials(_ context.Context, accessKey string) (*model.Credential, error)

func (*PlayBackMockConf) GetUserByID

func (m *PlayBackMockConf) GetUserByID(_ context.Context, userID int) (*model.User, error)

type ResponseWriter

type ResponseWriter struct {
	OriginalWriter http.ResponseWriter
	ResponseLog    *LazyOutput
	StatusCode     int
	Headers        http.Header
	UploadIDRegexp *regexp.Regexp
	// contains filtered or unexported fields
}

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

func (*ResponseWriter) SaveHeaders

func (w *ResponseWriter) SaveHeaders(fName string)

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(data []byte) (int, error)

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(statusCode int)

type StoredEvent

type StoredEvent struct {
	Status   int    `json:"status"`
	UploadID string `json:"uploadId"`
	Request  string `json:"request"`
}

Jump to

Keyboard shortcuts

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