client.go 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package misc
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "net/http"
  6. "github.com/G-Node/gogs/internal/conf"
  7. "github.com/G-Node/gogs/internal/context"
  8. log "gopkg.in/clog.v1"
  9. )
  10. type CLICongig struct {
  11. RSAHostKey string
  12. }
  13. type APICLIConfig struct {
  14. RSAKet string
  15. Weburl string
  16. Webport string
  17. SSHUrl string
  18. SSHUser string
  19. SSHPort int
  20. }
  21. func ClientC(c *context.APIContext) {
  22. cf := APICLIConfig{RSAKet: conf.CLIConfig.RSAHostKey,
  23. Weburl: fmt.Sprintf("%s://%s", conf.Server.Protocol, conf.Server.Domain),
  24. Webport: conf.Server.HTTPPort, SSHUrl: conf.SSH.Domain, SSHPort: conf.SSH.Port,
  25. SSHUser: conf.App.RunUser}
  26. data, err := json.Marshal(cf)
  27. if err != nil {
  28. log.Info("Could not determine client configuration: %+v", err)
  29. c.WriteHeader(http.StatusInternalServerError)
  30. return
  31. }
  32. c.WriteHeader(http.StatusOK)
  33. _, _ = c.Write(data)
  34. }