handler

package
v0.0.0-...-5bc8233 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType        = "Content-Type"
	HeaderLastModified       = "Last-Modified"
	HeaderRequestId          = "X-Request-ID"
	HeaderContentTypeOptions = "X-Content-Type-Options"
)
View Source
const (
	ContentTypeText = "text/plain; charset=utf-8"
	ContentTypeHTML = "text/html; charset=utf-8"
	ContentTypeJSON = "application/json; charset=utf-8"
)
View Source
const (
	KindTokenReview = "TokenReview"
)

Variables

View Source
var (
	ErrMissingToken   = errors.New("Missing token")
	ErrMalformedToken = errors.New("Token validation failed")
)
View Source
var DefaultGitlabURL, _ = url.Parse("https://gitlab.com/")

Functions

func LinearRequestIdentifier

func LinearRequestIdentifier(inc uint64, h http.Handler) http.Handler

LinearRequestIdentifier returns a middleware implementation which decorates incoming requests with HeaderRequestId headers using incremental values. The step size is defined by inc.

func RequestIdentifier

func RequestIdentifier(inc func() uint64, h http.Handler) http.Handler

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

func SystemRequestIdentifier(h http.Handler) http.Handler

SystemRequestIdentifier returns a middleware implementation which decorates incoming requests with HeaderRequestId headers derived from the system time.

func TimeRequestIdentifier

func TimeRequestIdentifier(now func() time.Time, h http.Handler) http.Handler

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)

type HealthHandlerOpts

type HealthHandlerOpts struct {
	// Header value for the reponses
	ContentType string
	// Response body for healthy states
	HealthyResponse string
	// Response body for unhealthy states
	UnhealthyResponse string
}

Jump to

Keyboard shortcuts

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