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.

39 lines
546 B

  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "net/http"
  6. )
  7. type Routes []Route
  8. var routes = Routes{
  9. Route{
  10. "Index",
  11. "GET",
  12. "/",
  13. Index,
  14. },
  15. Route{
  16. "GetPeers",
  17. "GET",
  18. "/peers",
  19. GetPeers,
  20. },
  21. }
  22. type Address struct {
  23. Address string `json:"address"` //the pubK of the user, to perform logins
  24. }
  25. func Index(w http.ResponseWriter, r *http.Request) {
  26. fmt.Fprintln(w, "CA")
  27. }
  28. func GetPeers(w http.ResponseWriter, r *http.Request) {
  29. getPeers()
  30. jResp, err := json.Marshal(peersList)
  31. check(err)
  32. fmt.Fprintln(w, string(jResp))
  33. }