web

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 10 Imported by: 19

Documentation

Index

Constants

View Source
const (
	NsParam      = "ns1"
	NsCollection = "namespaces"
	Root         = "/" + NsCollection + "/:" + NsParam
)

Root - all routes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorized

type Authorized struct {
	// Bearer token.
	Token string
}

Authorized by k8s bearer token.

func (*Authorized) Prepare

func (h *Authorized) Prepare(ctx *gin.Context) int

Prepare the handler to fulfil the request. Set the `token` field using passed parameters.

type Consistent

type Consistent struct {
}

Consistent (not-partial) request handler.

func (*Consistent) EnsureConsistency

func (c *Consistent) EnsureConsistency(r container.Reconciler, w time.Duration) int

Ensure that the

type Paged

type Paged struct {
	// The `page` parameter passed in the request.
	Page model.Page
}

Paged handler.

func (*Paged) Prepare

func (h *Paged) Prepare(ctx *gin.Context) int

Prepare the handler to fulfil the request. Set the `page` field using passed parameters.

type RequestHandler

type RequestHandler interface {
	// Add routes to the `gin` router.
	AddRoutes(*gin.Engine)
	// List resources in a REST collection.
	List(*gin.Context)
	// Get a specific REST resource.
	Get(*gin.Context)
}

Web request handler.

type SchemaHandler

type SchemaHandler struct {

	// Schema version
	Version string
	// Schema release.
	Release int
	// contains filtered or unexported fields
}

Schema (route) handler.

func (*SchemaHandler) AddRoutes

func (h *SchemaHandler) AddRoutes(r *gin.Engine)

Add routes.

func (SchemaHandler) Get

func (h SchemaHandler) Get(ctx *gin.Context)

Not supported.

func (*SchemaHandler) List

func (h *SchemaHandler) List(ctx *gin.Context)

List schema.

type WebServer

type WebServer struct {
	// The optional port.  Default: 8080
	Port int
	// Allowed CORS origins.
	AllowedOrigins []string
	// Reference to the container.
	Container *container.Container
	// Handlers
	Handlers []RequestHandler

	// TLS.
	TLS struct {
		// Enabled.
		Enabled bool
		// Certificate path.
		Certificate string
		// Key path
		Key string
	}
	// contains filtered or unexported fields
}

Web server

func New

func New(c *container.Container, routes ...RequestHandler) *WebServer

Build new web server.

func (*WebServer) Start

func (w *WebServer) Start()

Start the web-server. Initializes `gin` with routes and CORS origins. Creates an http server to handle TLS

Jump to

Keyboard shortcuts

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