subhandler

package
v0.0.0-...-95cd7c8 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CTXSubscribeTopic is the constant string that represents the subscribe function in context
	CTXSubscribeTopic = "subscription-subscribe-function"
	// CTXGraphQLWSID is the constant string that represents the websocket connection id in context
	CTXGraphQLWSID = "graphql-ws-id"
)

Variables

This section is empty.

Functions

func Subscribe

func Subscribe(ctx context.Context, topic string) error

Subscribe calls a subscription function from handler that has been passed through context

Types

type Notifier

type Notifier interface {
	// Subscribes the specified function from topic
	Subscribe(topic string, cb func(data map[string]interface{}))

	// Unsubscribes the specified function from topic
	Unsubscribe(topic string, cb func(data map[string]interface{}))

	// Notify notifies the topic with the optional data
	Notify(topic string, data map[string]interface{})
}

Notifier is a interface used for pub-sub like interactions

type SubscriptionHandler

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

func MakeSubscriptionHandler

func MakeSubscriptionHandler(notifier Notifier, schema graphql.Schema) *SubscriptionHandler

func (*SubscriptionHandler) ServeHTTP

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

func (*SubscriptionHandler) SetCheckOrigin

func (sh *SubscriptionHandler) SetCheckOrigin(fn func(r *http.Request) bool)

Jump to

Keyboard shortcuts

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