route

package
v0.0.0-...-ec8dcbf Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrometheusRoute = Routes{
	Route{
		"Prometeus metrics",
		http.MethodGet,
		"/metrics",
		promhttp.Handler().ServeHTTP,
		middleware.NoAuth,
	},
}

PrometheusRoute definition

View Source
var ReceiverRoutes = Routes{
	Route{
		"status",
		"GET",
		"/status",
		StatusPage,
		middleware.AuthHeaderRequired,
	},
	Route{
		"Receive",
		"POST",
		"/v1/firehose",
		ReceiveHandler,
		middleware.NoAuth,
	},
}

ReceiverRoutes definition

View Source
var RestRoutes = Routes{
	Route{
		"Get a function",
		"GET",
		"/v2/function/{tenant}/{function}",
		GetFunctionHandler,
		middleware.AuthVerifyJWT,
	},
	Route{
		"Create a function",
		"POST",
		"/v2/function/{tenant}/{function}",
		UpdateFunctionHandler,
		middleware.AuthVerifyJWT,
	},
	Route{
		"Delete a function",
		"DELETE",
		"/v2/function/{tenant}/{function}",
		DeleteFunctionHandler,
		middleware.AuthVerifyJWT,
	},
	Route{
		"Trigger a function",
		"PUT",
		"/v2/function",
		TriggerFunctionHandler,
		middleware.AuthVerifyJWT,
	},
}

RestRoutes definition

Functions

func ConsumerConfigFromHTTPParts

func ConsumerConfigFromHTTPParts(allowedClusters []string, h *http.Header, vars map[string]string, params url.Values) (token, topicFN, pulsarURL, subName string, subInitPos pulsar.SubscriptionInitialPosition, subType pulsar.SubscriptionType, err error)

ConsumerConfigFromHTTPParts returns configuration parameters required to generate Pulsar Client and Consumer

func ConsumerParams

func ConsumerParams(params url.Values) (subName string, subInitPos pulsar.SubscriptionInitialPosition, subType pulsar.SubscriptionType, err error)

ConsumerParams returns a configuration parameters for Pulsar consumer

func DeleteFunctionHandler

func DeleteFunctionHandler(w http.ResponseWriter, r *http.Request)

DeleteFunctionHandler deletes a function

func ExtractEvalTenant

func ExtractEvalTenant(requiredSubject, tokenSub string) bool

ExtractEvalTenant is a customized function to evaluate subject against tenant

func GetFunctionHandler

func GetFunctionHandler(w http.ResponseWriter, r *http.Request)

GetFunctionHandler gets a function

func GetTopicFnFromRoute

func GetTopicFnFromRoute(vars map[string]string) (string, error)

GetTopicFnFromRoute builds a valida topic fullname from the http route

func GetTopicKey

func GetTopicKey(r *http.Request) (string, error)

GetTopicKey gets the topic key from the request body or url sub route

func Init

func Init()

Init initializes database

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger logs http traffic.

func NewRouter

func NewRouter(mode *string) *mux.Router

NewRouter - create new router for HTTP routing

func ReceiveHandler

func ReceiveHandler(w http.ResponseWriter, r *http.Request)

ReceiveHandler - the message receiver handler

func StatusPage

func StatusPage(w http.ResponseWriter, r *http.Request)

StatusPage replies with basic status code

func TokenSubjectHandler

func TokenSubjectHandler(w http.ResponseWriter, r *http.Request)

TokenSubjectHandler issues new token

func TriggerFunctionHandler

func TriggerFunctionHandler(w http.ResponseWriter, r *http.Request)

TriggerFunctionHandler deletes a function

func UpdateFunctionHandler

func UpdateFunctionHandler(w http.ResponseWriter, r *http.Request)

UpdateFunctionHandler creates or updates a function

func VerifySubject

func VerifySubject(requiredSubject, tokenSubjects string, evalTenant func(tenant, subjects string) bool) bool

VerifySubject verifies the subject can meet the requirement. Subject verification requires role or tenant name in the jwt subject

func VerifySubjectBasedOnTopic

func VerifySubjectBasedOnTopic(topicFN, tokenSub string, evalTenant func(tenant, subjects string) bool) bool

VerifySubjectBasedOnTopic verifies the subject can meet the requirement.

Types

type ResponseErr

type ResponseErr struct {
	Error string `json:"error"`
}

ResponseErr - Error struct for Http response

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
	AuthFunc    mux.MiddlewareFunc
}

Route - HTTP Route

type Routes

type Routes []Route

Routes list of HTTP Routes

func GetEffectiveRoutes

func GetEffectiveRoutes(mode *string) Routes

GetEffectiveRoutes gets effective routes

type TokenServerResponse

type TokenServerResponse struct {
	Subject string `json:"subject"`
	Token   string `json:"token"`
}

TokenServerResponse is the json object for token server response

Jump to

Keyboard shortcuts

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