apihandler

package
v0.179.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 66 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"
	WgDeduplicateParam   = WgPrefix + "deduplicate"
)
View Source
const (
	JSONPatchConfigurationDisabled = JSONPatchConfiguration(0)
	JSONPatchConfigurationEnabled  = JSONPatchConfiguration(1)
	JSONPatchConfigurationForced   = JSONPatchConfiguration(2)
)
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, roundTripperOpts engineconfigloader.ApiTransportFactoryRoundTripperOptions, transportOpts ApiTransportOptions) http.RoundTripper

func NewApiTransportFactory added in v0.93.2

func NewApiTransportFactory(opts ApiTransportOptions) engineconfigloader.ApiTransportFactory

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
	Hooks                 []*hooks.Hook
}

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 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        GraphQLResolver
	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 GraphQLResolver added in v0.166.0

type GraphQLResolver interface {
	QueryResolver
	SubscriptionResolver
}

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
	DevMode             bool
}

type InternalSubscriptionApiHandler added in v0.129.0

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

func (*InternalSubscriptionApiHandler) ServeHTTP added in v0.129.0

type JSONPatchConfiguration added in v0.173.0

type JSONPatchConfiguration int

func (JSONPatchConfiguration) IsEnabled added in v0.173.0

func (c JSONPatchConfiguration) IsEnabled() bool

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
	Subscriptions       SubscriptionOptions
	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 SubscriptionOptions added in v0.173.0

type SubscriptionOptions struct {
	ServerPingInterval time.Duration
}

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 {
	JSONPatch     JSONPatchConfiguration
	SSE           bool
	SubscribeOnce bool
	Deduplicate   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