juju: github.com/juju/juju/apiserver/apiserverhttp Index | Files

package apiserverhttp

import "github.com/juju/juju/apiserver/apiserverhttp"

Index

Package Files

mux.go

type Mux Uses

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 Uses

func NewMux(opts ...muxOption) *Mux

NewMux returns a new, empty mux.

func (*Mux) AddClient Uses

func (m *Mux) AddClient()

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

func (*Mux) AddHandler Uses

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 Uses

func (m *Mux) ClientDone()

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

func (*Mux) RemoveHandler Uses

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 Uses

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 Uses

func (m *Mux) Wait()

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

Package apiserverhttp imports 4 packages (graph) and is imported by 34 packages. Updated 2018-05-19. Refresh now. Tools for package owners.