get token functionality added

This commit is contained in:
Suraj Patil 2016-09-20 22:24:04 +05:30
parent 4fa83089ee
commit 200f9c92ad
1 changed files with 14 additions and 1 deletions

View File

@ -1,11 +1,24 @@
package main package main
import "net/http" import "net/http"
import "net/url"
import "fmt" import "fmt"
import "io/ioutil" import "io/ioutil"
func main() { func main() {
resp, err := http.Get("http://127.0.0.1:8081/api/get-token") //client := &http.Client{}
//req, err := http.NewRequest("POST", "http://127.0.0.1:8081/api/get-token/", nil)
usernamePwd := url.Values{}
usernamePwd.Set("username", "suraj")
usernamePwd.Set("password", "suraj")
// if err != nil {
// fmt.Println("Unable to form a POST")
// }
//req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
//resp, err := client.Do(req)
resp, err := http.PostForm("http://127.0.0.1:8081/api/get-token/", usernamePwd)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }