Guest User

Untitled

a guest
Dec 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. HOST:
  2. host: http://sitex.com/
  3.  
  4. package main
  5.  
  6. import "net/http"
  7. import "net/url"
  8. import "bytes"
  9. import "github.com/jinzhu/configor"
  10. import "fmt"
  11.  
  12. var Config = struct {
  13. HOST struct {
  14. Host string `yaml:host`
  15. } `yaml:"HOST"`
  16.  
  17. }{}
  18.  
  19. configor.Load(&Config, "config.yml") */
  20. func Handler(host string, port int) {
  21. posthandl := url.Values {
  22. "username" : {"Jack"},
  23. }
  24.  
  25. form := bytes.NewBufferString(posthandl.Encode())
  26. req, err := http.Post(host, "application/x-www-form-urlencoded", form)
  27. if err != nil {
  28. fmt.Println(err)
  29. panic(err)
  30. } else {
  31. fmt.Println(req.Body)
  32. }
  33. }
  34.  
  35. func main() {
  36. Handler(Config.HOST.Host, 80) // так не работает, а если пропишу первым аргументом http://sitex.com/ то есть Handler("http://sitex.com/", 80) тогда все будет работать.
  37. }
Add Comment
Please, Sign In to add comment