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.

36 lines
774B

  1. package main
  2. import (
  3. "encoding/json"
  4. "io/ioutil"
  5. "log"
  6. )
  7. //WechatAPIConfig all secret related API Config
  8. type WechatAPIConfig struct {
  9. //Token is the wechat API shared secrete
  10. Token string `json:"Token"`
  11. //EncodingAESKey is the Key for encrypt messages
  12. EncodingAESKey string `'json:"EncodingAESKey"`
  13. //Appid is wechat public account appid
  14. Appid string `json:"Appid"`
  15. //AppSecret is how we identify ourselves.
  16. AppSecret string `json:"AppSecret"`
  17. }
  18. //APIConfig contains secrets that cannot store in source file
  19. var APIConfig WechatAPIConfig
  20. func readConfig() error {
  21. log.Printf("read config from %s\r\n", "server_config.json")
  22. body, err := ioutil.ReadFile("server_config.json")
  23. if err != nil {
  24. return err
  25. }
  26. return json.Unmarshal(body, &APIConfig)
  27. }