api

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func HTTPHandler added in v0.6.0

func HTTPHandler(resolver *Resolver, gqlEndpoint string) http.Handler

func MarshalULID added in v0.5.0

func MarshalULID(u ulid.ULID) graphql.Marshaler

func MarshalURL added in v0.5.0

func MarshalURL(u *url.URL) graphql.Marshaler

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func UnmarshalULID added in v0.5.0

func UnmarshalULID(v interface{}) (ulid.ULID, error)

func UnmarshalURL added in v0.5.0

func UnmarshalURL(v interface{}) (*url.URL, error)

Types

type CancelRequestResult added in v0.7.0

type CancelRequestResult struct {
	Success bool `json:"success"`
}

type CancelResponseResult added in v0.7.0

type CancelResponseResult struct {
	Success bool `json:"success"`
}

type ClearHTTPRequestLogResult added in v0.3.0

type ClearHTTPRequestLogResult struct {
	Success bool `json:"success"`
}

type CloseProjectResult added in v0.2.0

type CloseProjectResult struct {
	Success bool `json:"success"`
}

type ComplexityRoot

type ComplexityRoot struct {
	CancelRequestResult struct {
		Success func(childComplexity int) int
	}

	CancelResponseResult struct {
		Success func(childComplexity int) int
	}

	ClearHTTPRequestLogResult struct {
		Success func(childComplexity int) int
	}

	CloseProjectResult struct {
		Success func(childComplexity int) int
	}

	DeleteProjectResult struct {
		Success func(childComplexity int) int
	}

	DeleteSenderRequestsResult struct {
		Success func(childComplexity int) int
	}

	HTTPHeader struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	HTTPRequest struct {
		Body     func(childComplexity int) int
		Headers  func(childComplexity int) int
		ID       func(childComplexity int) int
		Method   func(childComplexity int) int
		Proto    func(childComplexity int) int
		Response func(childComplexity int) int
		URL      func(childComplexity int) int
	}

	HTTPRequestLog struct {
		Body      func(childComplexity int) int
		Headers   func(childComplexity int) int
		ID        func(childComplexity int) int
		Method    func(childComplexity int) int
		Proto     func(childComplexity int) int
		Response  func(childComplexity int) int
		Timestamp func(childComplexity int) int
		URL       func(childComplexity int) int
	}

	HTTPRequestLogFilter struct {
		OnlyInScope      func(childComplexity int) int
		SearchExpression func(childComplexity int) int
	}

	HTTPResponse struct {
		Body         func(childComplexity int) int
		Headers      func(childComplexity int) int
		ID           func(childComplexity int) int
		Proto        func(childComplexity int) int
		StatusCode   func(childComplexity int) int
		StatusReason func(childComplexity int) int
	}

	HTTPResponseLog struct {
		Body         func(childComplexity int) int
		Headers      func(childComplexity int) int
		ID           func(childComplexity int) int
		Proto        func(childComplexity int) int
		StatusCode   func(childComplexity int) int
		StatusReason func(childComplexity int) int
	}

	InterceptSettings struct {
		RequestFilter    func(childComplexity int) int
		RequestsEnabled  func(childComplexity int) int
		ResponseFilter   func(childComplexity int) int
		ResponsesEnabled func(childComplexity int) int
	}

	ModifyRequestResult struct {
		Success func(childComplexity int) int
	}

	ModifyResponseResult struct {
		Success func(childComplexity int) int
	}

	Mutation struct {
		CancelRequest                         func(childComplexity int, id ulid.ULID) int
		CancelResponse                        func(childComplexity int, requestID ulid.ULID) int
		ClearHTTPRequestLog                   func(childComplexity int) int
		CloseProject                          func(childComplexity int) int
		CreateOrUpdateSenderRequest           func(childComplexity int, request SenderRequestInput) int
		CreateProject                         func(childComplexity int, name string) int
		CreateSenderRequestFromHTTPRequestLog func(childComplexity int, id ulid.ULID) int
		DeleteProject                         func(childComplexity int, id ulid.ULID) int
		DeleteSenderRequests                  func(childComplexity int) int
		ModifyRequest                         func(childComplexity int, request ModifyRequestInput) int
		ModifyResponse                        func(childComplexity int, response ModifyResponseInput) int
		OpenProject                           func(childComplexity int, id ulid.ULID) int
		SendRequest                           func(childComplexity int, id ulid.ULID) int
		SetHTTPRequestLogFilter               func(childComplexity int, filter *HTTPRequestLogFilterInput) int
		SetScope                              func(childComplexity int, scope []ScopeRuleInput) int
		SetSenderRequestFilter                func(childComplexity int, filter *SenderRequestFilterInput) int
		UpdateInterceptSettings               func(childComplexity int, input UpdateInterceptSettingsInput) int
	}

	Project struct {
		ID       func(childComplexity int) int
		IsActive func(childComplexity int) int
		Name     func(childComplexity int) int
		Settings func(childComplexity int) int
	}

	ProjectSettings struct {
		Intercept func(childComplexity int) int
	}

	Query struct {
		ActiveProject        func(childComplexity int) int
		HTTPRequestLog       func(childComplexity int, id ulid.ULID) int
		HTTPRequestLogFilter func(childComplexity int) int
		HTTPRequestLogs      func(childComplexity int) int
		InterceptedRequest   func(childComplexity int, id ulid.ULID) int
		InterceptedRequests  func(childComplexity int) int
		Projects             func(childComplexity int) int
		Scope                func(childComplexity int) int
		SenderRequest        func(childComplexity int, id ulid.ULID) int
		SenderRequests       func(childComplexity int) int
	}

	ScopeHeader struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	ScopeRule struct {
		Body   func(childComplexity int) int
		Header func(childComplexity int) int
		URL    func(childComplexity int) int
	}

	SenderRequest struct {
		Body               func(childComplexity int) int
		Headers            func(childComplexity int) int
		ID                 func(childComplexity int) int
		Method             func(childComplexity int) int
		Proto              func(childComplexity int) int
		Response           func(childComplexity int) int
		SourceRequestLogID func(childComplexity int) int
		Timestamp          func(childComplexity int) int
		URL                func(childComplexity int) int
	}

	SenderRequestFilter struct {
		OnlyInScope      func(childComplexity int) int
		SearchExpression func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DeleteProjectResult added in v0.2.0

type DeleteProjectResult struct {
	Success bool `json:"success"`
}

type DeleteSenderRequestsResult added in v0.5.0

type DeleteSenderRequestsResult struct {
	Success bool `json:"success"`
}

type DirectiveRoot

type DirectiveRoot struct {
}

type HTTPHeader

type HTTPHeader struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type HTTPHeaderInput added in v0.5.0

type HTTPHeaderInput struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type HTTPMethod

type HTTPMethod string
const (
	HTTPMethodGet     HTTPMethod = "GET"
	HTTPMethodHead    HTTPMethod = "HEAD"
	HTTPMethodPost    HTTPMethod = "POST"
	HTTPMethodPut     HTTPMethod = "PUT"
	HTTPMethodDelete  HTTPMethod = "DELETE"
	HTTPMethodConnect HTTPMethod = "CONNECT"
	HTTPMethodOptions HTTPMethod = "OPTIONS"
	HTTPMethodTrace   HTTPMethod = "TRACE"
	HTTPMethodPatch   HTTPMethod = "PATCH"
)

func (HTTPMethod) IsValid

func (e HTTPMethod) IsValid() bool

func (HTTPMethod) MarshalGQL

func (e HTTPMethod) MarshalGQL(w io.Writer)

func (HTTPMethod) String

func (e HTTPMethod) String() string

func (*HTTPMethod) UnmarshalGQL

func (e *HTTPMethod) UnmarshalGQL(v interface{}) error

type HTTPProtocol added in v0.5.0

type HTTPProtocol string
const (
	HTTPProtocolHTTP10 HTTPProtocol = "HTTP10"
	HTTPProtocolHTTP11 HTTPProtocol = "HTTP11"
	HTTPProtocolHTTP20 HTTPProtocol = "HTTP20"
)

func (HTTPProtocol) IsValid added in v0.5.0

func (e HTTPProtocol) IsValid() bool

func (HTTPProtocol) MarshalGQL added in v0.5.0

func (e HTTPProtocol) MarshalGQL(w io.Writer)

func (HTTPProtocol) String added in v0.5.0

func (e HTTPProtocol) String() string

func (*HTTPProtocol) UnmarshalGQL added in v0.5.0

func (e *HTTPProtocol) UnmarshalGQL(v interface{}) error

type HTTPRequest added in v0.7.0

type HTTPRequest struct {
	ID       ulid.ULID     `json:"id"`
	URL      *url.URL      `json:"url"`
	Method   HTTPMethod    `json:"method"`
	Proto    HTTPProtocol  `json:"proto"`
	Headers  []HTTPHeader  `json:"headers"`
	Body     *string       `json:"body"`
	Response *HTTPResponse `json:"response"`
}

type HTTPRequestLog

type HTTPRequestLog struct {
	ID        ulid.ULID        `json:"id"`
	URL       string           `json:"url"`
	Method    HTTPMethod       `json:"method"`
	Proto     string           `json:"proto"`
	Headers   []HTTPHeader     `json:"headers"`
	Body      *string          `json:"body"`
	Timestamp time.Time        `json:"timestamp"`
	Response  *HTTPResponseLog `json:"response"`
}

type HTTPRequestLogFilter added in v0.2.0

type HTTPRequestLogFilter struct {
	OnlyInScope      bool    `json:"onlyInScope"`
	SearchExpression *string `json:"searchExpression"`
}

type HTTPRequestLogFilterInput added in v0.2.0

type HTTPRequestLogFilterInput struct {
	OnlyInScope      *bool   `json:"onlyInScope"`
	SearchExpression *string `json:"searchExpression"`
}

type HTTPResponse added in v0.7.0

type HTTPResponse struct {
	// Will be the same ID as its related request ID.
	ID           ulid.ULID    `json:"id"`
	Proto        HTTPProtocol `json:"proto"`
	StatusCode   int          `json:"statusCode"`
	StatusReason string       `json:"statusReason"`
	Body         *string      `json:"body"`
	Headers      []HTTPHeader `json:"headers"`
}

type HTTPResponseLog

type HTTPResponseLog struct {
	// Will be the same ID as its related request ID.
	ID           ulid.ULID    `json:"id"`
	Proto        HTTPProtocol `json:"proto"`
	StatusCode   int          `json:"statusCode"`
	StatusReason string       `json:"statusReason"`
	Body         *string      `json:"body"`
	Headers      []HTTPHeader `json:"headers"`
}

type InterceptSettings added in v0.7.0

type InterceptSettings struct {
	RequestsEnabled  bool    `json:"requestsEnabled"`
	ResponsesEnabled bool    `json:"responsesEnabled"`
	RequestFilter    *string `json:"requestFilter"`
	ResponseFilter   *string `json:"responseFilter"`
}

type ModifyRequestInput added in v0.7.0

type ModifyRequestInput struct {
	ID             ulid.ULID         `json:"id"`
	URL            *url.URL          `json:"url"`
	Method         HTTPMethod        `json:"method"`
	Proto          HTTPProtocol      `json:"proto"`
	Headers        []HTTPHeaderInput `json:"headers"`
	Body           *string           `json:"body"`
	ModifyResponse *bool             `json:"modifyResponse"`
}

type ModifyRequestResult added in v0.7.0

type ModifyRequestResult struct {
	Success bool `json:"success"`
}

type ModifyResponseInput added in v0.7.0

type ModifyResponseInput struct {
	RequestID    ulid.ULID         `json:"requestID"`
	Proto        HTTPProtocol      `json:"proto"`
	Headers      []HTTPHeaderInput `json:"headers"`
	Body         *string           `json:"body"`
	StatusCode   int               `json:"statusCode"`
	StatusReason string            `json:"statusReason"`
}

type ModifyResponseResult added in v0.7.0

type ModifyResponseResult struct {
	Success bool `json:"success"`
}

type MutationResolver added in v0.2.0

type MutationResolver interface {
	CreateProject(ctx context.Context, name string) (*Project, error)
	OpenProject(ctx context.Context, id ulid.ULID) (*Project, error)
	CloseProject(ctx context.Context) (*CloseProjectResult, error)
	DeleteProject(ctx context.Context, id ulid.ULID) (*DeleteProjectResult, error)
	ClearHTTPRequestLog(ctx context.Context) (*ClearHTTPRequestLogResult, error)
	SetScope(ctx context.Context, scope []ScopeRuleInput) ([]ScopeRule, error)
	SetHTTPRequestLogFilter(ctx context.Context, filter *HTTPRequestLogFilterInput) (*HTTPRequestLogFilter, error)
	SetSenderRequestFilter(ctx context.Context, filter *SenderRequestFilterInput) (*SenderRequestFilter, error)
	CreateOrUpdateSenderRequest(ctx context.Context, request SenderRequestInput) (*SenderRequest, error)
	CreateSenderRequestFromHTTPRequestLog(ctx context.Context, id ulid.ULID) (*SenderRequest, error)
	SendRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error)
	DeleteSenderRequests(ctx context.Context) (*DeleteSenderRequestsResult, error)
	ModifyRequest(ctx context.Context, request ModifyRequestInput) (*ModifyRequestResult, error)
	CancelRequest(ctx context.Context, id ulid.ULID) (*CancelRequestResult, error)
	ModifyResponse(ctx context.Context, response ModifyResponseInput) (*ModifyResponseResult, error)
	CancelResponse(ctx context.Context, requestID ulid.ULID) (*CancelResponseResult, error)
	UpdateInterceptSettings(ctx context.Context, input UpdateInterceptSettingsInput) (*InterceptSettings, error)
}

type Project added in v0.2.0

type Project struct {
	ID       ulid.ULID        `json:"id"`
	Name     string           `json:"name"`
	IsActive bool             `json:"isActive"`
	Settings *ProjectSettings `json:"settings"`
}

type ProjectSettings added in v0.7.0

type ProjectSettings struct {
	Intercept *InterceptSettings `json:"intercept"`
}

type QueryResolver

type QueryResolver interface {
	HTTPRequestLog(ctx context.Context, id ulid.ULID) (*HTTPRequestLog, error)
	HTTPRequestLogs(ctx context.Context) ([]HTTPRequestLog, error)
	HTTPRequestLogFilter(ctx context.Context) (*HTTPRequestLogFilter, error)
	ActiveProject(ctx context.Context) (*Project, error)
	Projects(ctx context.Context) ([]Project, error)
	Scope(ctx context.Context) ([]ScopeRule, error)
	SenderRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error)
	SenderRequests(ctx context.Context) ([]SenderRequest, error)
	InterceptedRequests(ctx context.Context) ([]HTTPRequest, error)
	InterceptedRequest(ctx context.Context, id ulid.ULID) (*HTTPRequest, error)
}

type Resolver

type Resolver struct {
	ProjectService    proj.Service
	RequestLogService reqlog.Service
	InterceptService  *intercept.Service
	SenderService     sender.Service
}

func (*Resolver) Mutation added in v0.2.0

func (r *Resolver) Mutation() MutationResolver

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type ScopeHeader added in v0.2.0

type ScopeHeader struct {
	Key   *string `json:"key"`
	Value *string `json:"value"`
}

type ScopeHeaderInput added in v0.2.0

type ScopeHeaderInput struct {
	Key   *string `json:"key"`
	Value *string `json:"value"`
}

type ScopeRule added in v0.2.0

type ScopeRule struct {
	URL    *string      `json:"url"`
	Header *ScopeHeader `json:"header"`
	Body   *string      `json:"body"`
}

type ScopeRuleInput added in v0.2.0

type ScopeRuleInput struct {
	URL    *string           `json:"url"`
	Header *ScopeHeaderInput `json:"header"`
	Body   *string           `json:"body"`
}

type SenderRequest added in v0.5.0

type SenderRequest struct {
	ID                 ulid.ULID        `json:"id"`
	SourceRequestLogID *ulid.ULID       `json:"sourceRequestLogID"`
	URL                *url.URL         `json:"url"`
	Method             HTTPMethod       `json:"method"`
	Proto              HTTPProtocol     `json:"proto"`
	Headers            []HTTPHeader     `json:"headers"`
	Body               *string          `json:"body"`
	Timestamp          time.Time        `json:"timestamp"`
	Response           *HTTPResponseLog `json:"response"`
}

type SenderRequestFilter added in v0.5.0

type SenderRequestFilter struct {
	OnlyInScope      bool    `json:"onlyInScope"`
	SearchExpression *string `json:"searchExpression"`
}

type SenderRequestFilterInput added in v0.5.0

type SenderRequestFilterInput struct {
	OnlyInScope      *bool   `json:"onlyInScope"`
	SearchExpression *string `json:"searchExpression"`
}

type SenderRequestInput added in v0.5.0

type SenderRequestInput struct {
	ID      *ulid.ULID        `json:"id"`
	URL     *url.URL          `json:"url"`
	Method  *HTTPMethod       `json:"method"`
	Proto   *HTTPProtocol     `json:"proto"`
	Headers []HTTPHeaderInput `json:"headers"`
	Body    *string           `json:"body"`
}

type UpdateInterceptSettingsInput added in v0.7.0

type UpdateInterceptSettingsInput struct {
	RequestsEnabled  bool    `json:"requestsEnabled"`
	ResponsesEnabled bool    `json:"responsesEnabled"`
	RequestFilter    *string `json:"requestFilter"`
	ResponseFilter   *string `json:"responseFilter"`
}

Jump to

Keyboard shortcuts

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