utils

package
v0.64.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateServer

func CreateServer(addr string, handlers func(x *mux.Router), options Options) *http.Server

func GenerateBearerToken

func GenerateBearerToken(key string, subject string, expires time.Time) (string, error)

func HealthHandlerFunctionWithChecks

func HealthHandlerFunctionWithChecks(w http.ResponseWriter, _ *http.Request, checks []HealthCheck)

func SetUpMockServer added in v0.62.1

func SetUpMockServer(key string, path string) *http.Server

This is a mock server that simply returns the http request infor as an OPA input structure to the requesting client. Main purpose is to test how OpaInput works against http.Request

func StartServer

func StartServer(server *http.Server, l net.Listener)

func StopServer

func StopServer(server *http.Server)

func WaitForHealthy

func WaitForHealthy(server *http.Server)

func WaitForHealthyWithClient

func WaitForHealthyWithClient(server *http.Server, client httpClient, url string)

Types

type HealthCheck

type HealthCheck interface {
	Name() string
	Check() bool
}

type NoopCheck

type NoopCheck struct {
}

func (*NoopCheck) Check

func (d *NoopCheck) Check() bool

func (*NoopCheck) Name

func (d *NoopCheck) Name() string

type Options

type Options struct {
	HealthChecks []HealthCheck
}

type Path

type Path struct {
	URI     string
	Methods []string
}

func Paths

func Paths(router *mux.Router) []Path

Jump to

Keyboard shortcuts

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