Documentation
¶
Index ¶
- Constants
- Variables
- func LinearRequestIdentifier(inc uint64, h http.Handler) http.Handler
- func RequestIdentifier(inc func() uint64, h http.Handler) http.Handler
- func SystemRequestIdentifier(h http.Handler) http.Handler
- func TimeRequestIdentifier(now func() time.Time, h http.Handler) http.Handler
- func WithAuthGroupFilter(v *gitlab.ListGroupsOptions) func(*AuthHandler)
- func WithAuthMetrics(v *metrics.Metrics) func(*AuthHandler)
- func WithAuthTokenValidator(v func(string) bool) func(*AuthHandler)
- func WithAuthUserACLs(v map[string]userauthz.Authorizer) func(*AuthHandler)
- func WithAuthUserCache(v *cache.UserInfoCache) func(*AuthHandler)
- func WithAuthUserTransform(v *access.UserInfoOptions) func(*AuthHandler)
- type AuthHandler
- type FilesystemHandler
- type FilesystemHandlerOpts
- type HealthHandler
- type HealthHandlerOpts
Constants ¶
const ( HeaderContentType = "Content-Type" HeaderLastModified = "Last-Modified" HeaderRequestId = "X-Request-ID" HeaderContentTypeOptions = "X-Content-Type-Options" )
const ( ContentTypeText = "text/plain; charset=utf-8" ContentTypeHTML = "text/html; charset=utf-8" ContentTypeJSON = "application/json; charset=utf-8" )
const (
KindTokenReview = "TokenReview"
)
Variables ¶
var ( ErrMissingToken = errors.New("Missing token") ErrMalformedToken = errors.New("Token validation failed") )
var DefaultGitlabURL, _ = url.Parse("https://gitlab.com/")
Functions ¶
func LinearRequestIdentifier ¶
LinearRequestIdentifier returns a middleware implementation which decorates incoming requests with HeaderRequestId headers using incremental values. The step size is defined by inc.
func RequestIdentifier ¶
RequestIdentifier wraps the given handler with a header injector using the provided increment provider as request identification mutator/generator. The request identifier is injected only if no existing value is present.
func SystemRequestIdentifier ¶
SystemRequestIdentifier returns a middleware implementation which decorates incoming requests with HeaderRequestId headers derived from the system time.
func TimeRequestIdentifier ¶
TimeRequestIdentifier returns a middleware implementation which decorates incoming requests with HeaderRequestId headers derived from the provided time generator. The algorithm input is using the value from Time.Unix as calculation base.
func WithAuthGroupFilter ¶
func WithAuthGroupFilter(v *gitlab.ListGroupsOptions) func(*AuthHandler)
func WithAuthMetrics ¶
func WithAuthMetrics(v *metrics.Metrics) func(*AuthHandler)
func WithAuthTokenValidator ¶
func WithAuthTokenValidator(v func(string) bool) func(*AuthHandler)
func WithAuthUserACLs ¶
func WithAuthUserACLs(v map[string]userauthz.Authorizer) func(*AuthHandler)
func WithAuthUserCache ¶
func WithAuthUserCache(v *cache.UserInfoCache) func(*AuthHandler)
func WithAuthUserTransform ¶
func WithAuthUserTransform(v *access.UserInfoOptions) func(*AuthHandler)
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(client *gitlab.Client, logger *slog.Logger, opts ...func(*AuthHandler)) (result *AuthHandler, err error)
func (*AuthHandler) ServeHTTP ¶
func (h *AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FilesystemHandler ¶
type FilesystemHandler struct {
// contains filtered or unexported fields
}
func FilesystemHandlerFor ¶
func FilesystemHandlerFor(dir string, opts FilesystemHandlerOpts) (*FilesystemHandler, error)
func (*FilesystemHandler) ServeHTTP ¶
func (h *FilesystemHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FilesystemHandlerOpts ¶
type FilesystemHandlerOpts struct {
// Application name
Name string
// Version information
Version string
// Freeform text describing the purpose of the application
Description string
// URL for users to visit for token generation
GitlabURL *url.URL
// Process start time to use as cache buster or information
StartTime time.Time
// Custom information to be used in the template
ExtraData map[string]interface{}
}
type HealthHandler ¶
type HealthHandler struct {
// contains filtered or unexported fields
}
func HealthHandlerFor ¶
func HealthHandlerFor(status *health.Health, opts HealthHandlerOpts) (*HealthHandler, error)
func (*HealthHandler) ServeHTTP ¶
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)