go-http-peering: forge.cadoles.com/wpetit/go-http-peering/server Index | Files

package server

import "forge.cadoles.com/wpetit/go-http-peering/server"

Index

Package Files

handler.go middleware.go option.go

Constants

const (
    ServerTokenHeader            = "X-Server-Token" // nolint: gosec
    ClientTokenHeader            = "X-Client-Token"
    KeyPeerID         ContextKey = "PeerID"
)

Variables

var (
    ErrInvalidAdvertisingRequest = errors.New("invalid advertising request")
    ErrInvalidUpdateRequest      = errors.New("invalid update request")
    ErrPeerRejected              = errors.New("peer rejected")
    ErrPeerIDAlreadyInUse        = errors.New("peer id already in use")
    ErrUnauthorized              = errors.New("unauthorized")
)
var (
    ErrInvalidClaims   = errors.New("invalid claims")
    ErrInvalidChecksum = errors.New("invalid checksum")
    ErrNotPeered       = errors.New("not peered")
)

func AdvertiseHandler Uses

func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) http.HandlerFunc

func Authenticate Uses

func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) func(http.Handler) http.Handler

func DefaultErrorHandler Uses

func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error)

func GetPeerID Uses

func GetPeerID(r *http.Request) (peering.PeerID, error)

func PingHandler Uses

func PingHandler(store peering.Store, funcs ...OptionFunc) http.HandlerFunc

func UpdateHandler Uses

func UpdateHandler(store peering.Store, funcs ...OptionFunc) http.HandlerFunc

type ContextKey Uses

type ContextKey string

type ErrorHandler Uses

type ErrorHandler func(http.ResponseWriter, *http.Request, error)

type Logger Uses

type Logger interface {
    Printf(string, ...interface{})
}

type OptionFunc Uses

type OptionFunc func(*Options)

func WithErrorHandler Uses

func WithErrorHandler(handler ErrorHandler) OptionFunc

func WithIgnoredClientTokenErrors Uses

func WithIgnoredClientTokenErrors(codes ...uint32) OptionFunc

func WithLogger Uses

func WithLogger(logger Logger) OptionFunc

func WithPeerAttributes Uses

func WithPeerAttributes(attrs ...string) OptionFunc

type Options Uses

type Options struct {
    PeerAttributes           []string
    ErrorHandler             ErrorHandler
    Logger                   Logger
    IgnoredClientTokenErrors []uint32
}

Package server imports 15 packages (graph) and is imported by 2 packages. Updated 2019-05-21. Refresh now. Tools for package owners.