diff --git a/cmd/stepd/main.go b/cmd/stepd/main.go index 849290c..743b8e9 100644 --- a/cmd/stepd/main.go +++ b/cmd/stepd/main.go @@ -4,7 +4,6 @@ package main import "os" import "log" import "time" -import "slices" import "errors" import "syscall" import "os/user" @@ -17,7 +16,6 @@ import "path/filepath" import "git.tebibyte.media/sashakoshka/step" import "git.tebibyte.media/sashakoshka/go-cli" import "git.tebibyte.media/sashakoshka/step/providers" -import "git.tebibyte.media/sashakoshka/goutil/container" import "git.tebibyte.media/sashakoshka/go-service/daemon" import "git.tebibyte.media/sashakoshka/go-service/rotate" import stephttp"git.tebibyte.media/sashakoshka/step/http" @@ -200,32 +198,14 @@ func main () { err = environment.Init(context.Background()) if err != nil { log.Fatal("XXX:", err) } - // set up the HTTP handler - rateLimit := 0.0 - if rateLimitStr := config.Get("http.rate-limit"); rateLimitStr != "" { - rateLimit, err = strconv.ParseFloat(rateLimitStr, 64) - if err != nil { log.Fatal("XXX bad value for rate limit", err) } - } + // initialize the HTTP handler handler := stephttp.Handler { - Environment: &environment, - Directories: config.Get("http.serve-directories") == "true", - StepExt: ucontainer.NewSet(slices.Clone(config["http.step-extension"])...), - Index: slices.Clone(config["http.index-file"]), - ErrorDocument: config.Get("http.error-document"), - DirectoryDocument: config.Get("http.directory-document"), - DenyAll: ucontainer.NewSet(configFileName), - RateLimit: time.Duration(rateLimit * float64(time.Second)), - TrustXForwardedFor: config.Get("http.trust-x-forwarded-for") == "true", - TrustCFConnectingIP: config.Get("http.trust-cf-connecting-ip") == "true", - } - if len(handler.StepExt) == 0 { - handler.StepExt.Add(".step") - } - if len(handler.Index) == 0 { - handler.Index = []string { "index.step", "index.html", "index" } + Environment: &environment, } err = handler.Init(ctx) if err != nil { log.Println("XXX", err) } + err = handler.Configure(config) + if err != nil { log.Println("XXX", err) } // set up the HTTP server httpServer := httpServerRoutine {