Skip to content

Commit

Permalink
Merge branch 'master' into meyskens/auth-visibility
Browse files Browse the repository at this point in the history
Signed-off-by: Dima Kharitonov <geakstr@me.com>
  • Loading branch information
geakstr authored Jul 24, 2023
2 parents 37e05a8 + 6e7a9e6 commit e663993
Show file tree
Hide file tree
Showing 10 changed files with 842 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/improbable-eng/grpc-web v0.15.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
golang.org/x/net v0.9.0
golang.org/x/sys v0.10.0
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
Expand Down
9 changes: 8 additions & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
gops "github.com/google/gops/agent"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"golang.org/x/sys/unix"
"google.golang.org/grpc"

Expand Down Expand Up @@ -50,11 +52,16 @@ func runServer(cfg *config.Config) {
)

handler := http.NewServeMux()
handler.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "ok")
})
handler.HandleFunc("/api/", func(resp http.ResponseWriter, req *http.Request) {
// NOTE: GRPC server handles requests with URL like "ui.UI/functionName"
req.URL.Path = req.URL.Path[len("/api/"):]
wrappedGrpc.ServeHTTP(resp, req)
})
h2cHandler := h2c.NewHandler(handler, &http2.Server{})

ctx, cancel := signal.NotifyContext(context.Background(), unix.SIGINT, unix.SIGTERM)
defer cancel()
Expand All @@ -63,7 +70,7 @@ func runServer(cfg *config.Config) {

httpSrv := &http.Server{
Addr: addr,
Handler: handler,
Handler: h2cHandler,
BaseContext: func(net.Listener) context.Context {
return ctx
},
Expand Down
240 changes: 240 additions & 0 deletions backend/vendor/golang.org/x/net/http2/h2c/h2c.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ github.com/spf13/pflag
golang.org/x/net/context
golang.org/x/net/http/httpguts
golang.org/x/net/http2
golang.org/x/net/http2/h2c
golang.org/x/net/http2/hpack
golang.org/x/net/idna
golang.org/x/net/internal/timeseries
Expand Down
67 changes: 67 additions & 0 deletions server/public/icons/logos/grafana-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e663993

Please sign in to comment.