diff pkg/middleware/jsonhandler.go @ 5712:6270951dda28 revive-cleanup

/interface{}/any/
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 20 Feb 2024 22:37:51 +0100
parents 5f47eeea988d
children
line wrap: on
line diff
--- a/pkg/middleware/jsonhandler.go	Tue Feb 20 22:22:57 2024 +0100
+++ b/pkg/middleware/jsonhandler.go	Tue Feb 20 22:37:51 2024 +0100
@@ -33,7 +33,7 @@
 	Code int
 	// Result is serialized to JSON.
 	// If the type is an io.Reader its copied through.
-	Result interface{}
+	Result any
 }
 
 // JSONDefaultLimit is default size limit in bytes of an accepted
@@ -45,7 +45,7 @@
 type JSONHandler struct {
 	// Input (if not nil) is called to fill a data structure
 	// returned by this function.
-	Input func(*http.Request) interface{}
+	Input func(*http.Request) any
 	// Handle is called to handle the incoming HTTP request.
 	// in is the data structure returned by Input. Its nil if Input is nil.
 	Handle func(rep *http.Request) (JSONResult, error)
@@ -89,7 +89,7 @@
 }
 
 // JSONInput extracts the de-serialized input from the context of the request.
-func JSONInput(req *http.Request) interface{} {
+func JSONInput(req *http.Request) any {
 	return req.Context().Value(jsonHandlerInputKey)
 }
 
@@ -201,7 +201,7 @@
 
 // SendJSON sends data JSON encoded to the response writer
 // with a given HTTP status code.
-func SendJSON(rw http.ResponseWriter, code int, data interface{}) {
+func SendJSON(rw http.ResponseWriter, code int, data any) {
 	rw.Header().Set("Content-Type", "application/json")
 	rw.Header().Set("X-Content-Type-Options", "nosniff")
 	rw.WriteHeader(code)