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:
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@ -352,6 +353,17 @@ func WithGatewayOpts(opts ...runtime.ServeMuxOption) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithReactUI add static single page app serving to the http server
|
||||
// subpath is the path in the read-only file embed.FS to use as root to serve
|
||||
// static content
|
||||
func WithReactUI(fs embed.FS, subpath string) Option {
|
||||
return func(o *options) {
|
||||
o.reactUI = fs
|
||||
o.reactUISubPath = subpath
|
||||
o.hasReactUI = true
|
||||
}
|
||||
}
|
||||
|
||||
type options struct {
|
||||
ctx context.Context
|
||||
name string
|
||||
@ -394,6 +406,10 @@ type options struct {
|
||||
gatewayOpts []runtime.ServeMuxOption
|
||||
cors cors.Options
|
||||
|
||||
reactUI embed.FS
|
||||
reactUISubPath string
|
||||
hasReactUI bool
|
||||
|
||||
error error
|
||||
gatewayPrefix string
|
||||
}
|
||||
|
Reference in New Issue
Block a user