service

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespacePattern = "/ns/{namespace:[a-zA-Z0-9]+}"
	KeyValuePattern  = "/ns/{namespace:[a-zA-Z0-9]+}/{key:[a-zA-Z0-9]+}"
	SearchPattern    = "/search/{namespace:[a-zA-Z0-9]+}"
	SchemaPattern    = "/schema/{namespace:[a-zA-Z0-9]+}"
	OpenAPIPattern   = "/{openapi|swagger}.json"
	BrokerPattern    = "/broker"
	SwaggerUIPattern = "/swaggerui/"
	SchemaId         = "_schema"

	EVENT_ITEM_ADDED        = "ITEM_ADDED"
	EVENT_ITEM_DELETED      = "ITEM_DELETED"
	EVENT_NAMESPACE_DELETED = "NAMESPACE_DELETED"
)
View Source
const (
	USER_HEADER = "USER_HEADER"
)

Variables

View Source
var (
	ErrInvalidArguments = errors.New("invalid arguments")
)

Functions

This section is empty.

Types

type Broker added in v1.1.0

type Broker struct {

	// Events are pushed to this channel by the main events-gathering routine
	Notifier chan []byte
	// contains filtered or unexported fields
}

func NewServer added in v1.1.0

func NewServer() (broker *Broker)

func (*Broker) ServeHTTP added in v1.1.0

func (broker *Broker) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type BrokerEvent added in v1.1.0

type BrokerEvent struct {
	Event     string      `json:"event"`
	User      string      `json:"user_id,omitempty"`
	Namespace string      `json:"namespace"`
	Key       string      `json:"key,omitempty"`
	Value     interface{} `json:"value,omitempty"`
}

type Database

type Database interface {
	Init()
	Upsert(namespace string, key string, value []byte) *database.DbError
	Get(namespace string, key string) ([]byte, *database.DbError)
	GetAll(namespace string) (map[string][]byte, *database.DbError)
	Delete(namespace string, key string) *database.DbError
	DeleteAll(namespace string) *database.DbError
	GetNamespaces() []string
}

type JWTAuthMiddleware added in v1.2.0

type JWTAuthMiddleware struct {
	VerifyBytes []byte
}

func (*JWTAuthMiddleware) GetMiddleWare added in v1.2.0

func (m *JWTAuthMiddleware) GetMiddleWare(r *mux.Router) func(next http.Handler) http.Handler

type Payload added in v1.2.0

type Payload struct {
	User string      `json:"user_id"`
	Data interface{} `json:"data"`
}

type Server

type Server struct {
	Address     string
	AuthEnabled bool
	// contains filtered or unexported fields
}

func (*Server) Init

func (s *Server) Init(db Database)

func (*Server) Notify added in v1.1.0

func (s *Server) Notify(event BrokerEvent)

type TestingRouter

type TestingRouter struct {
	Router *mux.Router
}

func (*TestingRouter) AddHandler

func (tr *TestingRouter) AddHandler(path string, handler func(http.ResponseWriter, *http.Request), queryParamsPairs ...string)

func (*TestingRouter) ExecuteRequest

func (tr *TestingRouter) ExecuteRequest(req *http.Request) *httptest.ResponseRecorder

Jump to

Keyboard shortcuts

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