Documentation ¶
Index ¶
- Constants
- Variables
- func GetFileSize(filename string) (fileSize int64)
- func MultiPartBody(paramName, filename string, fileRef io.Reader, params map[string]string) (body io.ReadWriter, contentType string, err error)
- func Request(entity HttpRequestEntity, method string, body io.Reader) (response *http.Response, err error)
- type ConnAuth
- type DefaultHttpGateway
- type HttpGateway
- type HttpRequestEntity
- type MultiPartBodyFunc
- type MultiPartUploadFunc
- type RequestAdaptor
- type RequestFunc
Constants ¶
View Source
const NO_CONTENT_TYPE string = ""
Variables ¶
View Source
var LargeMultiPartUpload = func(conn ConnAuth, paramName, filename string, fileSize int64, fileRef io.Reader, params map[string]string) (res *http.Response, err error) { var req *http.Request ms := multipartstreamer.New() if params != nil { lo.G.Debug("adding params for request: ", params) if err = ms.WriteFields(params); err != nil { lo.G.Error("writefields error: ", err) } } if fileSize == int64(-1) { fileSize = GetFileSize(filename) } ms.WriteReader(paramName, filename, fileSize, fileRef) if req, err = http.NewRequest("POST", conn.Url, nil); err == nil { if conn.Username != "" && conn.Password != "" { req.SetBasicAuth(conn.Username, conn.Password) } ms.SetupRequest(req) tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } client := &http.Client{Transport: tr} res, err = client.Do(req) } return }
View Source
var MultiPartUpload = func(conn ConnAuth, paramName, filename string, fileSize int64, fileRef io.Reader, params map[string]string) (res *http.Response, err error) { var contentType string var rbody io.Reader if rbody, contentType, err = MultiPartBody(paramName, filename, fileRef, params); err == nil { var req *http.Request if req, err = http.NewRequest("POST", conn.Url, rbody); err == nil { if conn.Username != "" && conn.Password != "" { req.SetBasicAuth(conn.Username, conn.Password) } req.Header.Set("Content-Type", contentType) client := NewTransportClient() res, err = client.Do(req) } } return }
View Source
var NewHttpGateway = func() HttpGateway { return &DefaultHttpGateway{} }
View Source
var NewRoundTripper = func() http.RoundTripper { return &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } }
Functions ¶
func GetFileSize ¶
GetFileSize - gets the filesize of a given path
func MultiPartBody ¶
Types ¶
type DefaultHttpGateway ¶
type DefaultHttpGateway struct{}
func (*DefaultHttpGateway) Get ¶
func (gateway *DefaultHttpGateway) Get(entity HttpRequestEntity) RequestAdaptor
func (*DefaultHttpGateway) Post ¶
func (gateway *DefaultHttpGateway) Post(entity HttpRequestEntity, body io.Reader) RequestAdaptor
func (*DefaultHttpGateway) Put ¶
func (gateway *DefaultHttpGateway) Put(entity HttpRequestEntity, body io.Reader) RequestAdaptor
type HttpGateway ¶
type HttpGateway interface { Get(HttpRequestEntity) RequestAdaptor Post(HttpRequestEntity, io.Reader) RequestAdaptor Put(HttpRequestEntity, io.Reader) RequestAdaptor }
type HttpRequestEntity ¶
type MultiPartBodyFunc ¶
type MultiPartUploadFunc ¶
type RequestAdaptor ¶
type RequestFunc ¶
Click to show internal directories.
Click to hide internal directories.