lnd: don't attempt to serve the possible non-existent swagger file

This commit is contained in:
Olaoluwa Osuntokun 2017-02-16 21:10:47 +08:00
parent db8c6d4cf4
commit 19a7778a7d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

8
lnd.go
View File

@ -196,13 +196,9 @@ func lndMain() error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mux := proxy.NewServeMux()
swaggerPattern := proxy.MustPattern(proxy.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "swagger"}, ""))
// TODO(roasbeef): accept path to swagger file as command-line option
mux.Handle("GET", swaggerPattern, func(w http.ResponseWriter, r *http.Request, p map[string]string) {
http.ServeFile(w, r, "lnrpc/rpc.swagger.json")
})
proxyOpts := []grpc.DialOption{grpc.WithInsecure()}
err = lnrpc.RegisterLightningHandlerFromEndpoint(ctx, mux, grpcEndpoint, proxyOpts)
err = lnrpc.RegisterLightningHandlerFromEndpoint(ctx, mux, grpcEndpoint,
proxyOpts)
if err != nil {
return err
}