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