http

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 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 ListenAndServe

func ListenAndServe(listen string, mux *Mux) error

Types

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 func(Request) *response.Response)

func (*Mux) Delete

func (m *Mux) Delete(name string, fn func(Request) *response.Response)

func (*Mux) Get

func (m *Mux) Get(name string, fn func(Request) *response.Response)

func (*Mux) Post

func (m *Mux) Post(name string, fn func(Request) *response.Response)

func (*Mux) Put

func (m *Mux) Put(name string, fn func(Request) *response.Response)

func (*Mux) RegisterRoute

func (m *Mux) RegisterRoute(method, name string, fn func(Request) *response.Response)

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