mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
chore(code): replace interface{} with any EE-6513 (#11986)
This commit is contained in:
parent
9c4935286f
commit
f0d43f941f
66 changed files with 231 additions and 231 deletions
|
@ -13,13 +13,13 @@ import (
|
|||
|
||||
// JSON encodes data to rw in JSON format. Returns a pointer to a
|
||||
// HandlerError if encoding fails.
|
||||
func JSON(rw http.ResponseWriter, data interface{}) *httperror.HandlerError {
|
||||
func JSON(rw http.ResponseWriter, data any) *httperror.HandlerError {
|
||||
return JSONWithStatus(rw, data, http.StatusOK)
|
||||
}
|
||||
|
||||
// JSONWithStatus encodes data to rw in JSON format with a specific status code.
|
||||
// Returns a pointer to a HandlerError if encoding fails.
|
||||
func JSONWithStatus(rw http.ResponseWriter, data interface{}, status int) *httperror.HandlerError {
|
||||
func JSONWithStatus(rw http.ResponseWriter, data any, status int) *httperror.HandlerError {
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
rw.WriteHeader(status)
|
||||
|
||||
|
@ -37,7 +37,7 @@ func JSONWithStatus(rw http.ResponseWriter, data interface{}, status int) *httpe
|
|||
|
||||
// JSON encodes data to rw in YAML format. Returns a pointer to a
|
||||
// HandlerError if encoding fails.
|
||||
func YAML(rw http.ResponseWriter, data interface{}) *httperror.HandlerError {
|
||||
func YAML(rw http.ResponseWriter, data any) *httperror.HandlerError {
|
||||
rw.Header().Set("Content-Type", "text/yaml")
|
||||
|
||||
strData, ok := data.(string)
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestJSONWithStatus(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
name string
|
||||
data interface{}
|
||||
data any
|
||||
status int
|
||||
}{
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ func TestJSON(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
name string
|
||||
data interface{}
|
||||
data any
|
||||
status int
|
||||
}{
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ func TestJSON(t *testing.T) {
|
|||
func TestYAML(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
data interface{}
|
||||
data any
|
||||
expected string
|
||||
invalid bool
|
||||
}{
|
||||
|
@ -105,7 +105,7 @@ func TestYAML(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "doesn't support an Object",
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
expected: "",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue