/
main.go
52 lines (46 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package vault
// import (
// "encoding/json"
// "log"
// "net/http"
// httptransport "github.com/go-kit/kit/transport/http"
// "golang.org/x/net/context"
// )
// func main() {
// ctx := context.Background()
// srv := hasherService{}
// http.Handle("/json/hash", httptransport.NewServer(
// ctx,
// makeHashEndpoint(srv),
// decodeHashRequest,
// encodeResponse,
// ))
// http.Handle("/json/validate", httptransport.NewServer(
// ctx,
// makeValidateEndpoint(srv),
// decodeValidateRequest,
// encodeResponse,
// ))
// addr := ":8080"
// log.Println("serving through", addr)
// log.Fatal(http.ListenAndServe(addr, nil))
// }
// func decodeHashRequest(ctx context.Context, r *http.Request) (interface{}, error) {
// var req hashRequest
// err := json.NewDecoder(r.Body).Decode(&req)
// if err != nil {
// return nil, err
// }
// return req, nil
// }
// func decodeValidateRequest(ctx context.Context, r *http.Request) (interface{}, error) {
// var req validateRequest
// err := json.NewDecoder(r.Body).Decode(&req)
// if err != nil {
// return nil, err
// }
// return req, nil
// }
// func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
// return json.NewEncoder(w).Encode(response)
// }