Files
varde/modules/webserver/webserver.go
T
Fabian Gasper 9b0b6b1ecf Finished changing structure to modules:
- ntfy
- keyserver
- webhook
- webserver
functional modules.
2026-07-21 09:45:56 +02:00

35 lines
751 B
Go

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 }