http

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPHandlers = map[string]process.Handler{
	"get":    processHTTPGet,
	"post":   processHTTPPost,
	"put":    processHTTPPut,
	"patch":  processHTTPPatch,
	"delete": processHTTPDelete,
	"head":   processHTTPHead,
	"send":   processHTTPSend,
}

HTTPHandlers the http handlers

Functions

func SetFileRoot added in v0.10.3

func SetFileRoot(root string) error

SetFileRoot SetFileRoot

Types

type Request

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

Request HTTP Request

func New

func New(url string) *Request

New make a new http Request

func (*Request) AddFile

func (r *Request) AddFile(name, file string) *Request

AddFile set the file

func (*Request) AddHeader

func (r *Request) AddHeader(name, value string) *Request

AddHeader set the request header

func (*Request) DelHeader

func (r *Request) DelHeader(name string) *Request

DelHeader unset the request header

func (*Request) Delete

func (r *Request) Delete(data interface{}) *Response

Delete send the DELETE request

func (*Request) Get

func (r *Request) Get() *Response

Get send the GET request

func (*Request) GetHeader

func (r *Request) GetHeader(name string) string

GetHeader get the request header

func (*Request) HasHeader

func (r *Request) HasHeader(name string) bool

HasHeader check if the header name is exists

func (*Request) Head

func (r *Request) Head(data interface{}) *Response

Head send the Head request

func (*Request) Patch

func (r *Request) Patch(data interface{}) *Response

Patch send the PATCH request

func (*Request) Post

func (r *Request) Post(data interface{}) *Response

Post send the POST request

func (*Request) Put

func (r *Request) Put(data interface{}) *Response

Put send the PUT request

func (*Request) Send

func (r *Request) Send(method string, data interface{}) *Response

Send send the request

func (*Request) SetHeader

func (r *Request) SetHeader(name string, value string) *Request

SetHeader set the request header

func (*Request) Upload

func (r *Request) Upload(file string, chunksize int) *Response

Upload upload a big file

func (*Request) WithHeader

func (r *Request) WithHeader(headers http.Header) *Request

WithHeader set the request headers

func (*Request) WithQuery

func (r *Request) WithQuery(values neturl.Values) *Request

WithQuery set the request query params

type Response

type Response struct {
	Status  int         `json:"status"`
	Data    interface{} `json:"data"`
	Headers http.Header `json:"headers"`
	Code    int         `json:"code"`
	Message string      `json:"message"`
}

Response HTTP Response

func ResponseError

func ResponseError(code int, message string) *Response

ResponseError return new error response

Jump to

Keyboard shortcuts

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