mirror of
https://github.com/lightninglabs/aperture.git
synced 2025-12-18 09:34:20 +01:00
config: add static file root
This commit is contained in:
@@ -22,6 +22,10 @@ type config struct {
|
|||||||
// to listen for requests.
|
// to listen for requests.
|
||||||
ListenAddr string `long:"listenaddr" description:"The interface we should listen on for client requests"`
|
ListenAddr string `long:"listenaddr" description:"The interface we should listen on for client requests"`
|
||||||
|
|
||||||
|
// StaticRoot is the folder where the static content served by the proxy
|
||||||
|
// is located.
|
||||||
|
StaticRoot string `long:"staticroot" description:"The folder where the static content is located."`
|
||||||
|
|
||||||
Authenticator *auth.Config `long:"authenticator" description:"Configuration for the authenticator."`
|
Authenticator *auth.Config `long:"authenticator" description:"Configuration for the authenticator."`
|
||||||
|
|
||||||
// Services is a list of JSON objects in string format, which specify
|
// Services is a list of JSON objects in string format, which specify
|
||||||
|
|||||||
4
kirin.go
4
kirin.go
@@ -42,7 +42,9 @@ func start() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
servicesProxy, err := proxy.New(authenticator, cfg.Services)
|
servicesProxy, err := proxy.New(
|
||||||
|
authenticator, cfg.Services, cfg.StaticRoot,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ type Proxy struct {
|
|||||||
// New returns a new Proxy instance that proxies between the services specified,
|
// New returns a new Proxy instance that proxies between the services specified,
|
||||||
// using the auth to validate each request's headers and get new challenge
|
// using the auth to validate each request's headers and get new challenge
|
||||||
// headers if necessary.
|
// headers if necessary.
|
||||||
func New(auth auth.Authenticator, services []*Service) (*Proxy, error) {
|
func New(auth auth.Authenticator, services []*Service, staticRoot string) (
|
||||||
|
*Proxy, error) {
|
||||||
|
|
||||||
err := prepareServices(services)
|
err := prepareServices(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -68,7 +70,7 @@ func New(auth auth.Authenticator, services []*Service) (*Proxy, error) {
|
|||||||
FlushInterval: -1,
|
FlushInterval: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
staticServer := http.FileServer(http.Dir("static"))
|
staticServer := http.FileServer(http.Dir(staticRoot))
|
||||||
|
|
||||||
return &Proxy{
|
return &Proxy{
|
||||||
server: grpcProxy,
|
server: grpcProxy,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func TestProxy(t *testing.T) {
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
auth := auth.NewMockAuthenticator()
|
auth := auth.NewMockAuthenticator()
|
||||||
proxy, err := proxy.New(auth, services)
|
proxy, err := proxy.New(auth, services, "static")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create new proxy: %v", err)
|
t.Fatalf("failed to create new proxy: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
listenaddr: "localhost:8081"
|
listenaddr: "localhost:8081"
|
||||||
|
staticroot: "./static"
|
||||||
debuglevel: "debug"
|
debuglevel: "debug"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|||||||
Reference in New Issue
Block a user