From e66691083a2455c29b50a2970c0aba1d6afca753 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 23 Oct 2024 20:34:57 +0200 Subject: Switch to http.Handler The used `func(http.ResponseWriter, *http.Request)` return values made the HTTP handler factory functions quite unreadable. Thus it is switched to the http.Handler type. --- view/version.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'view/version.go') diff --git a/view/version.go b/view/version.go index faf91b1..337200e 100644 --- a/view/version.go +++ b/view/version.go @@ -5,13 +5,15 @@ import ( "net/http" ) -func VersionRead(version string) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - if version == "" { - http.Error(w, "This build has no version information", http.StatusNotFound) - return - } +func VersionRead(version string) http.Handler { + return http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + if version == "" { + http.Error(w, "This build has no version information", http.StatusNotFound) + return + } - fmt.Fprintln(w, version) - } + fmt.Fprintln(w, version) + }, + ) } -- cgit v1.2.3-70-g09d2