router

package
v0.0.0-...-6f9a9ad Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTokenSigningMethod invalid token signing method
	// ErrInvalidTokenSigningMethod = errors.New("invalid token signing method")
	// ErrMissingRoleName missing role name
	ErrMissingRoleName = errors.New("missing role name")
	// ErrMissingSub missing sub
	ErrMissingSub = errors.New("missing sub")
)
View Source
var (
	// ErrParseURLFailed parsing url failed
	ErrParseURLFailed = errors.New("parsing url failed")
	// ErrInvalidTokenSigningMethod invalid token signing method
	ErrInvalidTokenSigningMethod = errors.New("invalid token signing method")
	// ErrMissingToken missing authentication token
	ErrMissingToken = httputils.NewBadRequestError("missing authentication token")
)
View Source
var (
	// TODO: consider: should we move all errors to a single errors file?
	ErrInvalidTransportMode = errors.New("invalid transport mode")
)

Functions

This section is empty.

Types

type AuthorizeResult

type AuthorizeResult string

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, req *http.Request, resource string, action string) (string, error)
}

authentication and autorization

func NewAuthorizer

func NewAuthorizer(options AuthorizerOptions, repo authRepo.Repository) (Authorizer, error)

type AuthorizerOptions

type AuthorizerOptions struct {
	AuthType         AuthorizerType
	JWTSigningMethod jwt.SigningMethod
	JwtSigningSecret string
	AuthRepo         authRepo.Repository
}

type AuthorizerType

type AuthorizerType string
const (
	AuthorizerTypeJWT AuthorizerType = "jwt"
)

type Endpoint

type Endpoint struct {
	Path             string
	RemotePath       string
	TransportMode    TransportMode
	RemotHost        string
	Method           string
	ExchangeName     string // rabbitmq exchange
	RoutingKey       string // rabbitmq routing key
	Authorized       bool
	Options          EndpointOptions
	UseSharedOptions bool //TODO: maybe we should think of a way of just using CERTAIN shared options

}

Endpoint defines an endpoint to be routed

type EndpointOptions

type EndpointOptions struct {
	*AuthorizerOptions
	*RouterOptions
}

type Endpoints

type Endpoints struct {
	Endpoints     []Endpoint
	SharedOptions EndpointOptions
}

type Gateway

type Gateway struct {
	Router     Router
	Authorizer Authorizer
	Endpoint   Endpoint
}

type Proxy

type Proxy struct {
	Endpoints      []Endpoints
	RequestHandler *mux.Router
}

TODO: consider changing this name

func (Proxy) HandleEndpoints

func (p Proxy) HandleEndpoints(ctx context.Context, repo authRepo.Repository, rabbitclient rabbit.RabbitClient) error

type Router

type Router interface {
	Route() http.HandlerFunc
}

routes requests

type RouterOptions

type RouterOptions struct {
}

type TransportMode

type TransportMode string

TransportMode defines the way in which a request will be routed/proxied

const (
	// TransportModeHTTP transports mode http
	TransportModeHTTP TransportMode = "http"
	// TransportModeAMQP amqp
	TransportModeAMQP TransportMode = "amqp"
)

Jump to

Keyboard shortcuts

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