mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 09:12:28 +00:00
service: add react web app serving option
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user