-
Notifications
You must be signed in to change notification settings - Fork 135
/
factory.go
46 lines (37 loc) · 1.1 KB
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package zac
import (
"github.com/openziti/xweb/v2"
"github.com/openziti/ziti/common/spa_handler"
log "github.com/sirupsen/logrus"
)
const (
Binding = "zac"
)
type ZitiAdminConsoleFactory struct {
}
var _ xweb.ApiHandlerFactory = &ZitiAdminConsoleFactory{}
func NewZitiAdminConsoleFactory() *ZitiAdminConsoleFactory {
return &ZitiAdminConsoleFactory{}
}
func (factory ZitiAdminConsoleFactory) Validate(*xweb.InstanceConfig) error {
return nil
}
func (factory ZitiAdminConsoleFactory) Binding() string {
return Binding
}
func (factory ZitiAdminConsoleFactory) New(_ *xweb.ServerConfig, options map[interface{}]interface{}) (xweb.ApiHandler, error) {
loc := options["location"]
if loc == nil || loc == "" {
log.Fatal("location must be supplied in " + Binding + " options")
}
indexFile := options["indexFile"]
if indexFile == nil || indexFile == "" {
indexFile = "index.html"
}
spa := &spa_handler.SinglePageAppHandler{
HttpHandler: spa_handler.SpaHandler(loc.(string), "/"+Binding, indexFile.(string)),
BindingKey: Binding,
}
log.Infof("initializing ZAC SPA Handler from %s", loc)
return spa, nil
}