server

package
v0.0.0-...-fad2219 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package server implements the config server

The server consists of an API handler and a store.

Package server implements the config server

The server consists of an API handler and a store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(s Store, authorized, unauthorized func(r *http.Request) Store) func(r *http.Request) Store

BasicAuth is the basic auth middleware that checks if a request is authorized by looking up the store for the key `auth:basic:user`. If allowed, it uses the authoried store, else the unauthorized store

func Handler

func Handler(s func(r *http.Request) Store) http.Handler

Handler returns a HTTP handler for the config server service

The store factory passed in is used to create a store for each request.

func SetBasicAuthInfo

func SetBasicAuthInfo(s Store, user, password string)

SetBasicAuthInfo sets the basic auth password for the provided user

Types

type Store

type Store interface {
	// GetSince returns all config changed since the last version
	//
	// Versions start from 1. Passing in a smaller version than
	// that would automatically fetch all config entries
	GetSince(version int) (newVersion int, configs map[string]string)

	// Set updates the connfig entry for the specific key
	Set(key string, val string)

	// History fetches changes for a specific key in reverse
	// chronological order.  The epoch can be used for
	// continuation with an empty string being the initial value
	History(key, epoch string) (newEpoch string, configs []string)
}

Store is the storage interface for the server. See NewReids/Store for an emplementation

func NewRedisStore

func NewRedisStore(address, ns string) Store

NewRedisStore creates a new redis-based store

The address is the redis server address in host:port format. The provided namespace is used to construct a prefix of the form "{fig_<ns>}" for all the keys

Jump to

Keyboard shortcuts

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