Skip to content

Commit 743d3bf

Browse files
committed
rename interface{} to any
1 parent b8cb21c commit 743d3bf

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

internals/proxy/middlewares/body.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (data BodyMiddleware) Use() http.Handler {
3333
}
3434

3535
var modifiedBody bool
36-
var bodyData map[string]interface{}
36+
var bodyData map[string]any
3737

3838
if !body.Empty {
3939
bodyData = body.Data
@@ -70,7 +70,7 @@ func (data BodyMiddleware) Use() http.Handler {
7070
})
7171
}
7272

73-
func getMessage(aliases []MessageAlias, data map[string]interface{}) (string, map[string]interface{}) {
73+
func getMessage(aliases []MessageAlias, data map[string]any) (string, map[string]any) {
7474
var content string
7575
var best int
7676

@@ -87,7 +87,7 @@ func getMessage(aliases []MessageAlias, data map[string]interface{}) (string, ma
8787
return content, data
8888
}
8989

90-
func processAlias(alias MessageAlias, data map[string]interface{}) (string, int, bool) {
90+
func processAlias(alias MessageAlias, data map[string]any) (string, int, bool) {
9191
aliasKey := alias.Alias
9292

9393
value, ok := utils.GetByPath(aliasKey, data)

internals/proxy/middlewares/template.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
type TemplateMiddleware struct {
1818
Next http.Handler
19-
Variables map[string]interface{}
19+
Variables map[string]any
2020
}
2121

2222
func (data TemplateMiddleware) Use() http.Handler {
@@ -30,7 +30,7 @@ func (data TemplateMiddleware) Use() http.Handler {
3030
log.Error("Could not get Request Body: ", err.Error())
3131
}
3232

33-
bodyData := map[string]interface{}{}
33+
bodyData := map[string]any{}
3434

3535
var modifiedBody bool
3636

@@ -100,7 +100,7 @@ func (data TemplateMiddleware) Use() http.Handler {
100100
})
101101
}
102102

103-
func TemplateBody(data map[string]interface{}, VARIABLES any) (map[string]interface{}, bool, error) {
103+
func TemplateBody(data map[string]any, VARIABLES any) (map[string]any, bool, error) {
104104
var modified bool
105105

106106
templatedData, err := templating.RenderJSONTemplate("body", data, VARIABLES)
@@ -139,7 +139,7 @@ func TemplatePath(reqUrl *url.URL, VARIABLES any) (string, bool, error) {
139139
return reqPath, modified, nil
140140
}
141141

142-
func TemplateQuery(reqUrl *url.URL, data map[string]interface{}, VARIABLES any) (string, map[string]interface{}, bool, error) {
142+
func TemplateQuery(reqUrl *url.URL, data map[string]any, VARIABLES any) (string, map[string]any, bool, error) {
143143
var modified bool
144144

145145
decodedQuery, _ := url.QueryUnescape(reqUrl.RawQuery)

utils/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
middlewares "github.com/codeshelldev/secured-signal-api/internals/proxy/middlewares"
1010
utils "github.com/codeshelldev/secured-signal-api/utils"
11+
"github.com/codeshelldev/secured-signal-api/utils/docker"
1112
log "github.com/codeshelldev/secured-signal-api/utils/logger"
1213

1314
"github.com/knadh/koanf/parsers/dotenv"
@@ -88,10 +89,10 @@ func LoadFile(path string, parser koanf.Parser) (*file.File) {
8889

8990
time.Sleep(10 * time.Second)
9091

91-
os.Exit(1)
92+
docker.Exit(1)
9293
}
9394

94-
f.Watch(func(event interface{}, err error) {
95+
f.Watch(func(event any, err error) {
9596
if err != nil {
9697
return
9798
}

utils/query/query.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func tryParseInt(str string) (int, bool) {
4444
return 0, false
4545
}
4646

47-
func ParseTypedQueryValues(values []string) interface{} {
48-
var result interface{}
47+
func ParseTypedQueryValues(values []string) any {
48+
var result any
4949

5050
raw := values[0]
5151

@@ -60,7 +60,7 @@ func ParseTypedQueryValues(values []string) interface{} {
6060

6161
parts := strings.Split(raw, ",")
6262

63-
var list []interface{}
63+
var list []any
6464

6565
for _, part := range parts {
6666
_intValue, _isInt := tryParseInt(part)
@@ -81,8 +81,8 @@ func ParseTypedQueryValues(values []string) interface{} {
8181
return result
8282
}
8383

84-
func ParseTypedQuery(query string, matchPrefix string) (map[string]interface{}) {
85-
addedData := map[string]interface{}{}
84+
func ParseTypedQuery(query string, matchPrefix string) (map[string]any) {
85+
addedData := map[string]any{}
8686

8787
queryData := ParseRawQuery(query)
8888

utils/request/request.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
type BodyType string
2020

2121
type Body struct {
22-
Data map[string]interface{}
22+
Data map[string]any
2323
Raw []byte
2424
Empty bool
2525
}
@@ -28,7 +28,7 @@ func (body Body) ToString() string {
2828
return string(body.Raw)
2929
}
3030

31-
func CreateBody(data map[string]interface{}) (Body, error) {
31+
func CreateBody(data map[string]any) (Body, error) {
3232
if len(data) <= 0 {
3333
err := errors.New("empty data map")
3434

@@ -51,8 +51,8 @@ func CreateBody(data map[string]interface{}) (Body, error) {
5151
}, nil
5252
}
5353

54-
func GetJsonData(body []byte) (map[string]interface{}, error) {
55-
var data map[string]interface{}
54+
func GetJsonData(body []byte) (map[string]any, error) {
55+
var data map[string]any
5656

5757
err := json.Unmarshal(body, &data)
5858

@@ -64,8 +64,8 @@ func GetJsonData(body []byte) (map[string]interface{}, error) {
6464
return data, nil
6565
}
6666

67-
func GetFormData(body []byte) (map[string]interface{}, error) {
68-
data := map[string]interface{}{}
67+
func GetFormData(body []byte) (map[string]any, error) {
68+
data := map[string]any{}
6969

7070
queryData := query.ParseRawQuery(string(body))
7171

@@ -110,7 +110,7 @@ func GetReqBody(w http.ResponseWriter, req *http.Request) (Body, error) {
110110
return Body{Empty: true}, nil
111111
}
112112

113-
var data map[string]interface{}
113+
var data map[string]any
114114

115115
switch GetBodyType(req) {
116116
case Json:

utils/templating/templating.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
"text/template"
1010
)
1111

12-
func normalize(value interface{}) string {
12+
func normalize(value any) string {
1313
switch str := value.(type) {
1414
case []string:
1515
return "[" + strings.Join(str, ",") + "]"
1616

17-
case []interface{}:
17+
case []any:
1818
items := make([]string, len(str))
1919

2020
for i, item := range str {
@@ -27,7 +27,7 @@ func normalize(value interface{}) string {
2727
}
2828
}
2929

30-
func normalizeJSON(value interface{}) string {
30+
func normalizeJSON(value any) string {
3131
jsonBytes, err := json.Marshal(value)
3232

3333
if err != nil {
@@ -63,7 +63,7 @@ func CreateTemplateWithFunc(name string, funcMap template.FuncMap) (*template.Te
6363
return template.New(name).Funcs(funcMap)
6464
}
6565

66-
func RenderJSONTemplate(name string, data map[string]interface{}, variables any) (map[string]interface{}, error) {
66+
func RenderJSONTemplate(name string, data map[string]any, variables any) (map[string]any, error) {
6767
jsonBytes, err := json.Marshal(data)
6868

6969
if err != nil {

utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ func GetByPath(path string, data any) (any, bool) {
5151
for _, key := range cleaned {
5252
switch currentDataType := current.(type) {
5353
// Case: Dictionary
54-
case map[string]interface{}:
54+
case map[string]any:
5555
value, ok := currentDataType[key]
5656
if !ok {
5757
return nil, false
5858
}
5959
current = value
6060

6161
// Case: Array
62-
case []interface{}:
62+
case []any:
6363
index, err := strconv.Atoi(key)
6464

6565
if err != nil || index < 0 || index >= len(currentDataType) {

0 commit comments

Comments
 (0)