http

package
v3.10.30 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = errors.New("route not found")
	ErrMethodNotAllowed = errors.New("method not allowed")
)

Functions

func NewClientTrace added in v3.10.28

func NewClientTrace(ctx context.Context, tr tracer.Tracer) *httptrace.ClientTrace

func NewRoundTripper

func NewRoundTripper(opts ...Option) http.RoundTripper

NewRoundTripper creates new http RoundTripper

func RegisterMethod added in v3.8.8

func RegisterMethod(method string) error

RegisterMethod adds support for custom HTTP method handlers

func RequestToContext

func RequestToContext(r *http.Request) context.Context

RequestToContext puts the `Authorization` header bearer token into context so calls to services will be authorized.

func Write

func Write(w http.ResponseWriter, contentType string, status int, body string)

Write sets the status and body on a http ResponseWriter

func WriteBadRequestError

func WriteBadRequestError(w http.ResponseWriter, err error)

WriteBadRequestError sets a 400 status code

func WriteInternalServerError

func WriteInternalServerError(w http.ResponseWriter, err error)

WriteInternalServerError sets a 500 status code

Types

type Option

type Option func(*Options)

Option func

func WithRouter

func WithRouter(r router.Router) Option

WithRouter sets the router.Router option

type Options

type Options struct {
	Router router.Router
}

Options struct

type Trie

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

Trie holds nodes for path based tree search

func NewTrie

func NewTrie() *Trie

NewTrie create new tree

func (*Trie) Insert

func (n *Trie) Insert(methods []string, pattern string, handler interface{}) error

Insert add elemenent to tree

func (*Trie) Search

func (n *Trie) Search(method string, path string) (interface{}, map[string]string, error)

Search try to find element in tree with path and method

Jump to

Keyboard shortcuts

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