service: add react web app serving option

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2022-06-03 13:12:19 +02:00
parent 9174446b2c
commit ec06b7c4a2
3 changed files with 34 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import (
"time"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"go.linka.cloud/grpc/react"
)
var defaultWebOptions = []grpcweb.Option{
@ -33,3 +35,15 @@ func (s *service) grpcWeb(opts ...grpcweb.Option) error {
}
return nil
}
func (s *service) reactApp() error {
if !s.opts.hasReactUI {
return nil
}
h, err := react.NewHandler(s.opts.reactUI, s.opts.reactUISubPath)
if err != nil {
return err
}
s.opts.mux.Handle("/", h)
return nil
}