Documentation ¶
Overview ¶
Package http provides basic http request/response method and definition
Index ¶
- Constants
- func ConstructParams(req Request) (err error)
- func GetUrlQueriesEncoded(params map[string]string) string
- func ParseFromHttpResponse(hr *http.Response, response Response) (err error)
- type BaseRequest
- func (r *BaseRequest) GetBodyReader() io.Reader
- func (r *BaseRequest) GetContentType() string
- func (r *BaseRequest) GetDomain() string
- func (r *BaseRequest) GetFile() []byte
- func (r *BaseRequest) GetHttpMethod() string
- func (r *BaseRequest) GetParams() map[string]string
- func (r *BaseRequest) GetPath() string
- func (r *BaseRequest) GetScheme() string
- func (r *BaseRequest) GetUrl() string
- func (r *BaseRequest) Init() *BaseRequest
- func (r *BaseRequest) SetContentType(contentType string)
- func (r *BaseRequest) SetDomain(domain string)
- func (r *BaseRequest) SetFile(byte []byte)
- func (r *BaseRequest) SetHttpMethod(method string)
- func (r *BaseRequest) SetPath(path string)
- func (r *BaseRequest) SetScheme(scheme string)
- type BaseResponse
- type ErrorResponse
- type Request
- type Response
Constants ¶
View Source
const ( POST = "POST" GET = "GET" PATCH = "PATCH" DELETE = "DELETE" HTTP = "http" HTTPS = "https" Domain = "api.apitable.com" Path = "/" )
View Source
const ( FormContent = "application/x-www-form-urlencoded" JsonContent = "application/json" )
Variables ¶
This section is empty.
Functions ¶
func ConstructParams ¶
func GetUrlQueriesEncoded ¶
Types ¶
type BaseRequest ¶
type BaseRequest struct {
// contains filtered or unexported fields
}
func (*BaseRequest) GetBodyReader ¶
func (r *BaseRequest) GetBodyReader() io.Reader
func (*BaseRequest) GetContentType ¶
func (r *BaseRequest) GetContentType() string
func (*BaseRequest) GetDomain ¶
func (r *BaseRequest) GetDomain() string
func (*BaseRequest) GetFile ¶
func (r *BaseRequest) GetFile() []byte
func (*BaseRequest) GetHttpMethod ¶
func (r *BaseRequest) GetHttpMethod() string
func (*BaseRequest) GetParams ¶
func (r *BaseRequest) GetParams() map[string]string
func (*BaseRequest) GetPath ¶
func (r *BaseRequest) GetPath() string
func (*BaseRequest) GetScheme ¶
func (r *BaseRequest) GetScheme() string
func (*BaseRequest) GetUrl ¶
func (r *BaseRequest) GetUrl() string
func (*BaseRequest) Init ¶
func (r *BaseRequest) Init() *BaseRequest
func (*BaseRequest) SetContentType ¶
func (r *BaseRequest) SetContentType(contentType string)
func (*BaseRequest) SetDomain ¶
func (r *BaseRequest) SetDomain(domain string)
func (*BaseRequest) SetFile ¶
func (r *BaseRequest) SetFile(byte []byte)
func (*BaseRequest) SetHttpMethod ¶
func (r *BaseRequest) SetHttpMethod(method string)
func (*BaseRequest) SetPath ¶
func (r *BaseRequest) SetPath(path string)
func (*BaseRequest) SetScheme ¶
func (r *BaseRequest) SetScheme(scheme string)
type BaseResponse ¶
type BaseResponse struct { Code int `json:"code"` Message string `json:"message"` Success bool `json:"success"` // unique request id, will be return each time request. // when positioning question, it's necessary to provider request id. RequestId *string }
func (*BaseResponse) ParseErrorFromHTTPResponse ¶
func (r *BaseResponse) ParseErrorFromHTTPResponse(body []byte) (err error)
type ErrorResponse ¶
type ErrorResponse struct {
BaseResponse
}
type Request ¶
type Request interface { GetBodyReader() io.Reader GetScheme() string GetDomain() string GetHttpMethod() string GetParams() map[string]string GetPath() string GetUrl() string GetContentType() string GetFile() []byte SetScheme(string) SetDomain(string) SetHttpMethod(string) SetPath(string) SetContentType(string) SetFile([]byte) }
Click to show internal directories.
Click to hide internal directories.