diff options
Diffstat (limited to 'pkg/handler/config')
| -rw-r--r-- | pkg/handler/config/handler.go | 16 | 
1 files changed, 7 insertions, 9 deletions
| diff --git a/pkg/handler/config/handler.go b/pkg/handler/config/handler.go index 30f4283..c43b54d 100644 --- a/pkg/handler/config/handler.go +++ b/pkg/handler/config/handler.go @@ -3,7 +3,6 @@ package config  import (  	"bytes"  	"encoding/json" -	"log/slog"  	"net/http"  	"github.com/alecthomas/chroma/v2/formatters/html" @@ -11,6 +10,7 @@ import (  	"github.com/alecthomas/chroma/v2/styles"  	"git.gabrielgio.me/cerrado/pkg/config" +	"git.gabrielgio.me/cerrado/pkg/ext"  	"git.gabrielgio.me/cerrado/templates"  ) @@ -21,8 +21,8 @@ type (  	}  ) -func ConfigFile(configRepo configurationRepository) func(http.ResponseWriter, *http.Request) { -	return func(w http.ResponseWriter, _ *http.Request) { +func ConfigFile(configRepo configurationRepository) ext.ErrorRequestHandler { +	return func(w http.ResponseWriter, _ *http.Request) error {  		config := struct {  			RootReadme   string @@ -34,8 +34,7 @@ func ConfigFile(configRepo configurationRepository) func(http.ResponseWriter, *h  		b, err := json.MarshalIndent(config, "", "  ")  		if err != nil { -			slog.Error("Error parsing json", "error", err) -			return +			return err  		}  		lexer := lexers.Get("json") @@ -45,15 +44,13 @@ func ConfigFile(configRepo configurationRepository) func(http.ResponseWriter, *h  		)  		iterator, err := lexer.Tokenise(nil, string(b))  		if err != nil { -			slog.Error("Error tokenise", "error", err) -			return +			return err  		}  		var code bytes.Buffer  		err = formatter.Format(&code, style, iterator)  		if err != nil { -			slog.Error("Error format", "error", err) -			return +			return err  		}  		hello := &templates.ConfigPage{ @@ -61,5 +58,6 @@ func ConfigFile(configRepo configurationRepository) func(http.ResponseWriter, *h  		}  		templates.WritePageTemplate(w, hello) +		return nil  	}  } | 
