apiserverhttp

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mux

type Mux struct {
	// contains filtered or unexported fields
}

Mux is a pattern-based HTTP muxer, based on top of bmizerany/pat, adding support for dynamic registration and deregistration of handlers. When a handler is added or removed, the underlying pat mux is swapped out with a new one.

Adding and removing handlers is expensive: each of those calls will create a new mux underneath. These operations are not expected to be frequently occurring.

func NewMux

func NewMux(opts ...muxOption) *Mux

NewMux returns a new, empty mux.

func (*Mux) AddClient

func (m *Mux) AddClient()

AddClient tells the mux there's another client that should keep it alive.

func (*Mux) AddHandler

func (m *Mux) AddHandler(meth, pat string, h http.Handler) error

AddHandler adds an http.Handler for the given method and pattern. AddHandler returns an error if there already exists a handler for the method and pattern.

This is safe to call concurrently with m.ServeHTTP and m.RemoveHandler.

func (*Mux) ClientDone

func (m *Mux) ClientDone()

ClientDone indicates that a client has finished and no longer needs the mux.

func (*Mux) RemoveHandler

func (m *Mux) RemoveHandler(meth, pat string)

RemoveHandler removes the http.Handler for the given method and pattern, if any. If there is no handler registered with the method and pattern, this is a no-op.

This is safe to call concurrently with m.ServeHTTP and m.AddHandler.

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is part of the http.Handler interface.

ServeHTTP routes the request to a handler registered with AddHandler, according to the rules defined by bmizerany/pat.

func (*Mux) Wait

func (m *Mux) Wait()

Wait will block until all of the clients have indicated that they're done.

Jump to

Keyboard shortcuts

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