Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HOST:
- host: http://sitex.com/
- package main
- import "net/http"
- import "net/url"
- import "bytes"
- import "github.com/jinzhu/configor"
- import "fmt"
- var Config = struct {
- HOST struct {
- Host string `yaml:host`
- } `yaml:"HOST"`
- }{}
- configor.Load(&Config, "config.yml") */
- func Handler(host string, port int) {
- posthandl := url.Values {
- "username" : {"Jack"},
- }
- form := bytes.NewBufferString(posthandl.Encode())
- req, err := http.Post(host, "application/x-www-form-urlencoded", form)
- if err != nil {
- fmt.Println(err)
- panic(err)
- } else {
- fmt.Println(req.Body)
- }
- }
- func main() {
- Handler(Config.HOST.Host, 80) // так не работает, а если пропишу первым аргументом http://sitex.com/ то есть Handler("http://sitex.com/", 80) тогда все будет работать.
- }
Add Comment
Please, Sign In to add comment