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

@ -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
}