Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dovholuknf committed Feb 28, 2024
1 parent 5b2d67e commit e8080bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions common/spa_handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ type SinglePageAppHandler struct {
BindingKey string
}

func (self *SinglePageAppHandler) Binding() string {
return self.BindingKey
func (spa *SinglePageAppHandler) Binding() string {
return spa.BindingKey
}

func (self *SinglePageAppHandler) Options() map[interface{}]interface{} {
func (spa *SinglePageAppHandler) Options() map[interface{}]interface{} {
return nil
}

func (self *SinglePageAppHandler) RootPath() string {
return "/" + self.BindingKey
func (spa *SinglePageAppHandler) RootPath() string {
return "/" + spa.BindingKey
}

func (self *SinglePageAppHandler) IsHandler(r *http.Request) bool {
return strings.HasPrefix(r.URL.Path, self.RootPath()) || strings.HasPrefix(r.URL.Path, "/assets")
func (spa *SinglePageAppHandler) IsHandler(r *http.Request) bool {
return strings.HasPrefix(r.URL.Path, spa.RootPath()) || strings.HasPrefix(r.URL.Path, "/assets")
}

func (self *SinglePageAppHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
self.HttpHandler.ServeHTTP(writer, request)
func (spa *SinglePageAppHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
spa.HttpHandler.ServeHTTP(writer, request)
}

// Thanks to https://github.com/roberthodgen/spa-server
Expand Down
2 changes: 1 addition & 1 deletion controller/zac/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (factory ZitiAdminConsoleFactory) Binding() string {
func (factory ZitiAdminConsoleFactory) New(_ *xweb.ServerConfig, options map[interface{}]interface{}) (xweb.ApiHandler, error) {
loc := options["location"]
if loc == nil || loc == "" {
log.Panic("location must be supplied in spa options")
log.Fatal("location must be supplied in " + Binding + " options")
}
indexFile := options["indexFile"]
if indexFile == nil || indexFile == "" {
Expand Down

0 comments on commit e8080bd

Please sign in to comment.