Documentation ¶
Index ¶
- Constants
- func Get(client *http.Client, reqUrl string, reqParams map[string]string, ...) (*http.Response, error)
- func PostFile(client *http.Client, reqUrl string, reqParams map[string]string, ...) (*http.Response, error)
- func PostForm(client *http.Client, reqUrl string, reqParams map[string]string, ...) (*http.Response, error)
- func PostJson(client *http.Client, reqUrl string, reqParams map[string]string, ...) (*http.Response, error)
- type FileUploadInfo
Examples ¶
Constants ¶
View Source
const ( FORM_MULTIPART = "multipart/form-data" FORM_ENCODED = "application/x-www-form-urlencoded" APPLICATION_JSON = "application/json" CONTENT_TYPE = "Content-Type" )
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(client *http.Client, reqUrl string, reqParams map[string]string, headers map[string]string) (*http.Response, error)
Get request to target url http server
func PostFile ¶
func PostFile(client *http.Client, reqUrl string, reqParams map[string]string, files []FileUploadInfo, headers map[string]string) (*http.Response, error)
PostFile to post files to http server
Example ¶
package main import ( "fmt" "io/ioutil" "net/http" "github.com/jhunters/goassist/web/client" ) func main() { files := []client.FileUploadInfo{ {Name: "file", Filepath: `../../testresources/hello.txt`, FileName: "hello_upload.txt"}, } var httpClient = &http.Client{} response, err := client.PostFile(httpClient, "http://localhost:8080/FileTest", map[string]string{}, files, map[string]string{}) if err != nil { fmt.Println(err) return } if response != nil { content, _ := ioutil.ReadAll(response.Body) defer response.Body.Close() fmt.Println(string(content)) } }
Output:
Types ¶
type FileUploadInfo ¶
FileUploadInfo upload file info struct
Click to show internal directories.
Click to hide internal directories.