互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

5 years ago
  1. package test
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/kirinlabs/HttpRequest"
  6. "io/ioutil"
  7. )
  8. const RootHost = "http://127.0.0.1:20181"
  9. const ActivityId = 19
  10. const UserId = 19
  11. type ApiConfig struct {
  12. Host string `json:"host"`
  13. ActivityId int64 `json:"activity_id"` // 互动id
  14. UserId int64 `json:"user_id"` //用户id
  15. UserToken string `json:"user_token"` // token
  16. CustomerId string `json:"customer_id"`
  17. CustomerToken string `json:"customer_token"`
  18. CustomerName string `json:"customer_name"`
  19. CustomerPwd string `json:"customer_pwd"`
  20. EntryAccount string `json:"entry_account"`
  21. EntryPwd string `json:"entry_pwd"`
  22. EntryToken string `json:"entry_token"`
  23. }
  24. // get 方法
  25. func Api(token string) *HttpRequest.Request {
  26. return HttpRequest.NewRequest().Debug(true).SetHeaders(map[string]string{
  27. "token": token,
  28. })
  29. }
  30. func ApiUrl(path string) string {
  31. return fmt.Sprintf("%s/%s", RootHost, path)
  32. }
  33. func GetConfig() *ApiConfig {
  34. bs, err := ioutil.ReadFile("api.json")
  35. if err != nil {
  36. panic(err)
  37. }
  38. config := new(ApiConfig)
  39. err = json.Unmarshal(bs, config)
  40. if err != nil {
  41. panic(err)
  42. }
  43. return config
  44. }