Finished changing structure to modules:
- ntfy - keyserver - webhook - webserver functional modules.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package keyserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"varde/internal/middleware"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
KeysDir string
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
cfg Config
|
||||
}
|
||||
|
||||
func New(cfg Config) *Module {
|
||||
return &Module{cfg: cfg}
|
||||
}
|
||||
|
||||
func (m *Module) Name() string { return "keyserver" }
|
||||
|
||||
func (m *Module) RegisterRoutes(r *mux.Router) {
|
||||
fs := http.FileServer(http.Dir(m.cfg.KeysDir))
|
||||
wkd := r.PathPrefix("/.well-known/").Subrouter()
|
||||
wkd.Use(middleware.NoListing)
|
||||
wkd.Use(middleware.WKDHeaders)
|
||||
wkd.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