From 6e5062488fc3ecbf37c11e7d111bfe6ea3b5284d Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 5 Oct 2024 16:53:15 +0200 Subject: feat: Remove config page That page was created as playground and had some debug purpose. Now that is not longer used and with introduction of sensible information (hash and aes-key) that has to go. --- pkg/handler/config/handler.go | 63 ------------------------------------------- pkg/handler/router.go | 7 ++--- 2 files changed, 2 insertions(+), 68 deletions(-) delete mode 100644 pkg/handler/config/handler.go (limited to 'pkg/handler') diff --git a/pkg/handler/config/handler.go b/pkg/handler/config/handler.go deleted file mode 100644 index c43b54d..0000000 --- a/pkg/handler/config/handler.go +++ /dev/null @@ -1,63 +0,0 @@ -package config - -import ( - "bytes" - "encoding/json" - "net/http" - - "github.com/alecthomas/chroma/v2/formatters/html" - "github.com/alecthomas/chroma/v2/lexers" - "github.com/alecthomas/chroma/v2/styles" - - "git.gabrielgio.me/cerrado/pkg/config" - "git.gabrielgio.me/cerrado/pkg/ext" - "git.gabrielgio.me/cerrado/templates" -) - -type ( - configurationRepository interface { - GetRootReadme() string - List() []*config.GitRepositoryConfiguration - } -) - -func ConfigFile(configRepo configurationRepository) ext.ErrorRequestHandler { - return func(w http.ResponseWriter, _ *http.Request) error { - - config := struct { - RootReadme string - Repositories []*config.GitRepositoryConfiguration - }{ - RootReadme: configRepo.GetRootReadme(), - Repositories: configRepo.List(), - } - - b, err := json.MarshalIndent(config, "", " ") - if err != nil { - return err - } - - lexer := lexers.Get("json") - style := styles.Get("monokailight") - formatter := html.New( - html.WithLineNumbers(true), - ) - iterator, err := lexer.Tokenise(nil, string(b)) - if err != nil { - return err - } - - var code bytes.Buffer - err = formatter.Format(&code, style, iterator) - if err != nil { - return err - } - - hello := &templates.ConfigPage{ - Body: code.Bytes(), - } - - templates.WritePageTemplate(w, hello) - return nil - } -} diff --git a/pkg/handler/router.go b/pkg/handler/router.go index f464ac2..a2ac98a 100644 --- a/pkg/handler/router.go +++ b/pkg/handler/router.go @@ -6,7 +6,6 @@ import ( serverconfig "git.gabrielgio.me/cerrado/pkg/config" "git.gabrielgio.me/cerrado/pkg/ext" "git.gabrielgio.me/cerrado/pkg/handler/about" - "git.gabrielgio.me/cerrado/pkg/handler/config" "git.gabrielgio.me/cerrado/pkg/handler/git" "git.gabrielgio.me/cerrado/pkg/handler/static" "git.gabrielgio.me/cerrado/pkg/service" @@ -20,9 +19,8 @@ func MountHandler( configRepo *serverconfig.ConfigurationRepository, ) (http.Handler, error) { var ( - gitHandler = git.NewGitHandler(gitService, configRepo) - aboutHandler = about.NewAboutHandler(configRepo) - configHandler = config.ConfigFile(configRepo) + gitHandler = git.NewGitHandler(gitService, configRepo) + aboutHandler = about.NewAboutHandler(configRepo) ) staticHandler, err := static.ServeStaticHandler() @@ -43,7 +41,6 @@ func MountHandler( mux.HandleFunc("/{name}/log/{ref}/", gitHandler.Log) mux.HandleFunc("/{name}/commit/{ref}/", gitHandler.Commit) mux.HandleFunc("/{name}/archive/{file}", gitHandler.Archive) - mux.HandleFunc("/config", configHandler) mux.HandleFunc("/about", aboutHandler.About) mux.HandleFunc("/", gitHandler.List) return mux.Handler(), nil -- cgit v1.2.3