http

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{}
View Source
var DefaultHeader = map[string]string{
	"User-Agent": "jk-http-client/1.7.1",
}

Functions

func AnyServer added in v2.6.0

func AnyServer(listen, path string, fn Handler) error

func GetServer added in v2.6.0

func GetServer(listen, path string, fn Handler) error

func ListenAndServe

func ListenAndServe(listen string, mux *Mux) error

func PostServer added in v2.6.0

func PostServer(listen, path string, fn Handler) error

Types

type Handler added in v2.6.0

type Handler func(Request) *response.Response

type Mux

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

func NewMux

func NewMux() *Mux

func (*Mux) Any

func (m *Mux) Any(name string, fn Handler)

func (*Mux) Delete

func (m *Mux) Delete(name string, fn Handler)

func (*Mux) Get

func (m *Mux) Get(name string, fn Handler)

func (*Mux) Post

func (m *Mux) Post(name string, fn Handler)

func (*Mux) Put

func (m *Mux) Put(name string, fn Handler)

func (*Mux) RegisterRoute

func (m *Mux) RegisterRoute(method, name string, fn Handler)

func (*Mux) Trace

func (m *Mux) Trace(name string)

type Request

type Request struct {
	*http.Request
	Query url.Values
}

func (*Request) ReadBody added in v2.3.0

func (r *Request) ReadBody() ([]byte, error)

func (*Request) ReadBodyReckless added in v2.3.0

func (r *Request) ReadBodyReckless() []byte

func (*Request) RemoteHost added in v2.3.0

func (r *Request) RemoteHost() string

func (*Request) RemotePort added in v2.3.0

func (r *Request) RemotePort() int

func (*Request) Unmarshal

func (r *Request) Unmarshal(v any) error

type Response added in v2.3.0

type Response struct {
	*http.Response `json:"base"`
	StatusCode     int    `json:"status_code"`
	Body           []byte `json:"body"`
}

func Get

func Get(url string, headers ...map[string]string) (*Response, error)

func Post

func Post(url string, data any, headers ...map[string]string) (*Response, error)

func Raw

func Raw(method, url string, data []byte, headers map[string]string) (*Response, error)

Jump to

Keyboard shortcuts

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