http

package
v2.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 11 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 Output added in v2.8.0

func Output(url string, w io.Writer, headers ...map[string]string) (int, error)

func PostServer added in v2.6.0

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

func Wget added in v2.8.0

func Wget(url string, name string, headers ...map[string]string) (int, 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) ListenAndServe added in v2.9.0

func (m *Mux) ListenAndServe(listen string) error

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
	Writer http.ResponseWriter
	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) RemoteHostIn added in v2.8.1

func (r *Request) RemoteHostIn(list ...string) bool

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