middleware

package
Version: v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContactContext

func ContactContext(next http.Handler) http.Handler

ContactContext gets contactID from parsed URI corresponding to trigger routes and set it to request context

func DatabaseContext

func DatabaseContext(database moira.Database) func(next http.Handler) http.Handler

DatabaseContext sets to requests context configured database

func DateRange

func DateRange(defaultFrom, defaultTo string) func(next http.Handler) http.Handler

DateRange gets from and to values from URI query and set it to request context. If query has not values sets given values

func GetContactID

func GetContactID(request *http.Request) string

GetContactID gets ContactID string from request context, which was sets in TriggerContext middleware

func GetDatabase

func GetDatabase(request *http.Request) moira.Database

GetDatabase gets moira.Database realization from request context

func GetFromStr

func GetFromStr(request *http.Request) string

GetFromStr gets 'from' value from request context, which was sets in DateRange middleware

func GetLoggerEntry

func GetLoggerEntry(request *http.Request) moira.Logger

GetLoggerEntry gets logger entry with configured logger

func GetLogin

func GetLogin(request *http.Request) string

GetLogin gets user login string from request context, which was sets in UserContext middleware

func GetPage

func GetPage(request *http.Request) int64

GetPage gets page value from request context, which was sets in Paginate middleware

func GetSize

func GetSize(request *http.Request) int64

GetSize gets size value from request context, which was sets in Paginate middleware

func GetSubscriptionID

func GetSubscriptionID(request *http.Request) string

GetSubscriptionID gets subscriptionId string from request context, which was sets in SubscriptionContext middleware

func GetTag

func GetTag(request *http.Request) string

GetTag gets tag string from request context, which was sets in TagContext middleware

func GetTimeSeriesNames

func GetTimeSeriesNames(request *http.Request) map[string]bool

GetTimeSeriesNames gets from requests context timeSeriesNames from saved trigger

func GetToStr

func GetToStr(request *http.Request) string

GetToStr gets 'to' value from request context, which was sets in DateRange middleware

func GetTriggerID

func GetTriggerID(request *http.Request) string

GetTriggerID gets TriggerID string from request context, which was sets in TriggerContext middleware

func GetTriggerTargetsSourceProvider added in v2.5.0

func GetTriggerTargetsSourceProvider(request *http.Request) *metricSource.SourceProvider

GetTriggerTargetsSourceProvider gets trigger targets source provider

func MetricSourceProvider added in v2.5.0

func MetricSourceProvider(sourceProvider *metricSource.SourceProvider) func(next http.Handler) http.Handler

MetricSourceProvider adds metrics source provider to context

func Paginate

func Paginate(defaultPage, defaultSize int64) func(next http.Handler) http.Handler

Paginate gets page and size values from URI query and set it to request context. If query has not values sets given values

func RequestLogger

func RequestLogger(logger moira.Logger) func(next http.Handler) http.Handler

RequestLogger is overload method of go-chi.middleware RequestLogger with custom response logging

func SearchIndexContext added in v2.4.0

func SearchIndexContext(searcher moira.Searcher) func(next http.Handler) http.Handler

SearchIndexContext sets to requests context configured moira.index.searchIndex

func SetTimeSeriesNames

func SetTimeSeriesNames(request *http.Request, timeSeriesNames map[string]bool)

SetTimeSeriesNames sets to requests context timeSeriesNames from saved trigger

func SubscriptionContext

func SubscriptionContext(next http.Handler) http.Handler

SubscriptionContext gets subscriptionId from parsed URI corresponding to subscription routes and set it to request context

func TagContext

func TagContext(next http.Handler) http.Handler

TagContext gets tagName from parsed URI corresponding to tag routes and set it to request context

func TriggerContext

func TriggerContext(next http.Handler) http.Handler

TriggerContext gets triggerId from parsed URI corresponding to trigger routes and set it to request context

func UserContext

func UserContext(next http.Handler) http.Handler

UserContext get x-webauth-user header and sets it in request context, if header is empty sets empty string

func WithLogEntry

func WithLogEntry(r *http.Request, entry *apiLoggerEntry) *http.Request

WithLogEntry sets to context configured logger entry

Types

type ContextKey

type ContextKey string

ContextKey used as key of api request context values

func (ContextKey) String

func (key ContextKey) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL