function update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
"crowdsec-dashy/internal/geoip"
|
||||
"crowdsec-dashy/internal/handlers"
|
||||
"crowdsec-dashy/internal/middleware"
|
||||
"crowdsec-dashy/internal/store"
|
||||
)
|
||||
|
||||
// New constructs the full HTTP handler: renderer, deps, routes, and middleware chain.
|
||||
@@ -18,6 +20,11 @@ func New(cfg *config.Config, lapi *crowdsec.LAPIClient, webFS fs.FS, geoUpdater
|
||||
return nil, err
|
||||
}
|
||||
|
||||
st, err := store.New(cfg.DataFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("data store: %w", err)
|
||||
}
|
||||
|
||||
deps := handlers.Deps{
|
||||
Renderer: renderer,
|
||||
LAPI: lapi,
|
||||
@@ -26,6 +33,7 @@ func New(cfg *config.Config, lapi *crowdsec.LAPIClient, webFS fs.FS, geoUpdater
|
||||
PollInterval: cfg.PollIntervalSec,
|
||||
CrowdsecBinPath: cfg.CrowdsecBinPath,
|
||||
CrowdsecConfigDir: cfg.CrowdsecConfigDir,
|
||||
Store: st,
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
@@ -90,6 +98,8 @@ func New(cfg *config.Config, lapi *crowdsec.LAPIClient, webFS fs.FS, geoUpdater
|
||||
// Allowlist
|
||||
alw := handlers.NewAllowlistHandler(deps)
|
||||
mux.HandleFunc("GET /allowlist", alw.List)
|
||||
mux.HandleFunc("POST /allowlist/create", alw.CreateList)
|
||||
mux.HandleFunc("POST /allowlist/delete-list", alw.DeleteList)
|
||||
mux.HandleFunc("POST /allowlist/add", alw.AddEntry)
|
||||
mux.HandleFunc("POST /allowlist/remove", alw.RemoveEntry)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user