Finished changing structure to modules:
- ntfy - keyserver - webhook - webserver functional modules.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package webserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
ContentDir string
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
cfg Config
|
||||
}
|
||||
|
||||
func New(cfg Config) *Module {
|
||||
return &Module{cfg: cfg}
|
||||
}
|
||||
|
||||
func (m *Module) Name() string { return "webserver" }
|
||||
|
||||
// RegisterRoutes uses a catch-all "/" handler — must be registered
|
||||
// LAST in main.go, after any more specific routes (keyserver, webhook),
|
||||
// since gorilla/mux matches in registration order.
|
||||
func (m *Module) RegisterRoutes(r *mux.Router) {
|
||||
fs := http.FileServer(http.Dir(m.cfg.ContentDir))
|
||||
r.PathPrefix("/").Handler(fs)
|
||||
}
|
||||
|
||||
func (m *Module) Start(ctx context.Context) error { return nil }
|
||||
func (m *Module) Stop(ctx context.Context) error { return nil }
|
||||
Reference in New Issue
Block a user