Documentation
¶
Index ¶
- func SetHandler(fn func(*Response))
- func SetLog(fn func(...any))
- type Header
- type Request
- func (r *Request) Body(data []byte) *Request
- func (r *Request) ContentTypeBinary() *Request
- func (r *Request) ContentTypeForm() *Request
- func (r *Request) ContentTypeHTML() *Request
- func (r *Request) ContentTypeJSON() *Request
- func (r *Request) ContentTypeText() *Request
- func (r *Request) Dispatch()
- func (r *Request) Header(key, value string) *Request
- func (r *Request) Send(callback func(*Response, error))
- func (r *Request) Timeout(ms int) *Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetHandler ¶ added in v0.1.13
func SetHandler(fn func(*Response))
SetHandler sets the global handler for Dispatch requests.
Types ¶
type Request ¶ added in v0.1.13
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request builder.
func (*Request) ContentTypeBinary ¶ added in v0.1.13
ContentTypeBinary sets Content-Type to application/octet-stream
func (*Request) ContentTypeForm ¶ added in v0.1.13
ContentTypeForm sets Content-Type to application/x-www-form-urlencoded
func (*Request) ContentTypeHTML ¶ added in v0.1.13
ContentTypeHTML sets Content-Type to text/html
func (*Request) ContentTypeJSON ¶ added in v0.1.13
ContentTypeJSON sets Content-Type to application/json
func (*Request) ContentTypeText ¶ added in v0.1.13
ContentTypeText sets Content-Type to text/plain
func (*Request) Dispatch ¶ added in v0.1.13
func (r *Request) Dispatch()
Dispatch executes the request and sends the response to the global handler. This is a fire-and-forget method.
type Response ¶ added in v0.1.13
type Response struct {
Status int
Headers []Header
RequestURL string
Method string
// contains filtered or unexported fields
}
Response represents an HTTP response.
Click to show internal directories.
Click to hide internal directories.