http-GET-POST

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 4 Imported by: 0

README

http-GET-POST

Using the standard net/http package to http.Get and http.PostForm.

GitHub Webpage

http.Get

Uses http.Get and ioutil.ReadAll,

url := "https://httpbin.org/post"

response, err := http.Get(url)

defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)

fmt.Printf("\nContent is:\n\n%s\n", string(contents))

http.PostForm

How to update over an http api using http.PostForm,

formData := url.Values{
    "name": {"jeff"},
}
url := "https://httpbin.org/post"

response, err := http.PostForm(url, formData)

defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)

fmt.Printf("\nPOST is:\n\n%s\n", string(contents))

RUN

go run get.go
go run postform.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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