apihandler

package
v0.158.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WgEnvCsrfSecret = "WG_CSRF_TOKEN_SECRET"
	WgEnvHashKey    = "WG_SECURE_COOKIE_HASH_KEY"
	WgEnvBlockKey   = "WG_SECURE_COOKIE_BLOCK_KEY"
)
View Source
const (
	WgInternalApiCallHeader = "X-WG-Internal-GraphQL-API"

	WgPrefix             = "wg_"
	WgVariables          = WgPrefix + "variables"
	WgLiveParam          = WgPrefix + "live"
	WgJsonPatchParam     = WgPrefix + "json_patch"
	WgSseParam           = WgPrefix + "sse"
	WgSubscribeOnceParam = WgPrefix + "subscribe_once"
)
View Source
const (
	ErrMsgOperationParseFailed         = "failed to parse operation: %w"
	ErrMsgOperationNormalizationFailed = "failed to normalize operation: %w"
	ErrMsgOperationValidationFailed    = "operation validation failed: %w"
	ErrMsgOperationPlanningFailed      = "operation planning failed: %w"
)

Variables

This section is empty.

Functions

func MergeJsonRightIntoLeft

func MergeJsonRightIntoLeft(left, right []byte) []byte

MergeJsonRightIntoLeft merges the right JSON into the left JSON while overriding the left side

func NewApiTransport

func NewApiTransport(httpTransport *http.Transport, enableStreamingMode bool, opts ApiTransportOptions) http.RoundTripper

func NewRequestFromWunderGraphClientRequest added in v0.92.0

func NewRequestFromWunderGraphClientRequest(ctx context.Context, body []byte) (*http.Request, error)

Types

type Api added in v0.110.0

type Api struct {
	PrimaryHost           string
	Hosts                 []string
	EngineConfiguration   *wgpb.EngineConfiguration
	EnableSingleFlight    bool
	EnableGraphqlEndpoint bool
	Operations            []*wgpb.Operation
	InvalidOperationNames []string
	CorsConfiguration     *wgpb.CorsConfiguration
	ApiConfigHash         string
	AuthenticationConfig  *wgpb.ApiAuthenticationConfig
	S3UploadConfiguration []*wgpb.S3UploadConfiguration
	Webhooks              []*wgpb.WebhookConfiguration
	Options               *Options
	CookieBasedSecrets    *CookieBasedSecrets
}

func (*Api) HasCookieAuthEnabled added in v0.110.0

func (api *Api) HasCookieAuthEnabled() bool

type ApiTransport

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

func (*ApiTransport) RoundTrip

func (t *ApiTransport) RoundTrip(request *http.Request) (*http.Response, error)

type ApiTransportFactory added in v0.112.0

type ApiTransportFactory interface {
	RoundTripper(transport *http.Transport, enableStreamingMode bool) http.RoundTripper
	DefaultTransportTimeout() time.Duration
	DefaultHTTPProxyURL() *url.URL
}

func NewApiTransportFactory added in v0.93.2

func NewApiTransportFactory(opts ApiTransportOptions) ApiTransportFactory

type ApiTransportOptions added in v0.144.0

type ApiTransportOptions struct {
	API                  *Api
	HooksClient          *hooks.Client
	EnableRequestLogging bool
	EnableTracing        bool
	Metrics              metrics.Metrics
}

type Builder

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

func NewBuilder

func NewBuilder(pool *pool.Pool,
	log *zap.Logger,
	loader *engineconfigloader.EngineConfigLoader,
	hooksClient *hooks.Client,
	config BuilderConfig,
) *Builder

func (*Builder) BuildAndMountApiHandler

func (r *Builder) BuildAndMountApiHandler(ctx context.Context, router *mux.Router, api *Api, planCache *ristretto.Cache) (streamClosers []chan struct{}, err error)

func (*Builder) Close added in v0.120.0

func (r *Builder) Close() error

type BuilderConfig

type BuilderConfig struct {
	InsecureCookies            bool
	ForceHttpsRedirects        bool
	EnableRequestLogging       bool
	EnableIntrospection        bool
	GitHubAuthDemoClientID     string
	GitHubAuthDemoClientSecret string
	DevMode                    bool
	Metrics                    metrics.Metrics
}

type Claims

type Claims struct {
	Name string `json:"name"`
	jwt.StandardClaims
}

type CookieBasedSecrets added in v0.131.2

type CookieBasedSecrets struct {
	CsrfSecret []byte
	BlockKey   []byte
	HashKey    []byte
}

func NewCookieBasedSecrets added in v0.131.2

func NewCookieBasedSecrets() (cookieBasedSecrets *CookieBasedSecrets, warnMessages []string)

func NewDevModeCookieBasedSecrets added in v0.131.2

func NewDevModeCookieBasedSecrets() (cookieBasedSecrets *CookieBasedSecrets, errorMessages []string)

type EndpointUnavailableHandler

type EndpointUnavailableHandler struct {
	OperationName string
	Logger        *zap.Logger
}

func (*EndpointUnavailableHandler) ServeHTTP

type FunctionsHandler added in v0.126.0

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

func (*FunctionsHandler) ServeHTTP added in v0.126.0

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

type GraphQLHandler

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

func (*GraphQLHandler) ServeHTTP

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

type GraphQLHandlerOptions added in v0.153.0

type GraphQLHandlerOptions struct {
	// GraphQLBaseURL indicates the base URL used by the playground to query the GraphQL API.
	// The GraphQL endpoint is determined as {GraphQLBaseURL}/graphql
	GraphQLBaseURL  string
	Internal        bool
	PlanConfig      plan.Configuration
	Definition      *ast.Document
	Resolver        *resolve.Resolver
	RenameTypeNames []resolve.RenameTypeName
	Pool            *pool.Pool
	Cache           *ristretto.Cache
	Log             *zap.Logger
}

type GraphQLPlaygroundHandler

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

func (*GraphQLPlaygroundHandler) ServeHTTP

type InternalApiHandler

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

func (*InternalApiHandler) ServeHTTP

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

type InternalBuilder

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

func NewInternalBuilder

func NewInternalBuilder(config InternalBuilderConfig) *InternalBuilder

func (*InternalBuilder) BuildAndMountInternalApiHandler

func (i *InternalBuilder) BuildAndMountInternalApiHandler(ctx context.Context, router *mux.Router, api *Api, planCache *ristretto.Cache) (streamClosers []chan struct{}, err error)

type InternalBuilderConfig added in v0.153.0

type InternalBuilderConfig struct {
	Pool                *pool.Pool
	Client              *hooks.Client
	Loader              *engineconfigloader.EngineConfigLoader
	EnableIntrospection bool
	InsecureCookies     bool
	Metrics             metrics.Metrics
	Log                 *zap.Logger
}

type InternalSubscriptionApiHandler added in v0.129.0

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

func (*InternalSubscriptionApiHandler) ServeHTTP added in v0.129.0

type Listener added in v0.110.0

type Listener struct {
	Host string
	Port uint16
}

type Logging added in v0.110.0

type Logging struct {
	Level zapcore.Level
}

type MutationHandler

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

func (*MutationHandler) ServeHTTP

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

type OpenTelemetry added in v0.157.0

type OpenTelemetry struct {
	Enabled              bool
	ExporterHTTPEndpoint string
	AuthToken            string
	Sampler              float64
}

type Options added in v0.110.0

type Options struct {
	ServerUrl           string
	PublicNodeUrl       string
	Listener            *Listener
	InternalListener    *Listener
	Logging             Logging
	DefaultTimeout      time.Duration
	DefaultHTTPProxyURL *url.URL
	Prometheus          PrometheusOptions
	OpenTelemetry       OpenTelemetry
}

type PrometheusOptions added in v0.154.0

type PrometheusOptions struct {
	Enabled bool
	Port    int
}

type QueryHandler

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

func (*QueryHandler) ServeHTTP

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

type QueryResolver

type QueryResolver interface {
	ResolveGraphQLResponse(ctx *resolve.Context, response *resolve.GraphQLResponse, data []byte, writer io.Writer) (err error)
}

type SubscriptionHandler

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

func (*SubscriptionHandler) ServeHTTP

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

type SubscriptionResolver added in v0.131.1

type SubscriptionResolver interface {
	ResolveGraphQLSubscription(ctx *resolve.Context, subscription *resolve.GraphQLSubscription, writer resolve.FlushWriter) (err error)
}

type WgRequestParams added in v0.131.1

type WgRequestParams struct {
	UseJsonPatch bool
	UseSse       bool
	SubsribeOnce bool
}

func NewWgRequestParams added in v0.131.1

func NewWgRequestParams(r *http.Request) WgRequestParams

Jump to

Keyboard shortcuts

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