Skip to content

Commit 0ff9a05

Browse files
committed
go fmt'ed all go files
1 parent 2e783ed commit 0ff9a05

File tree

21 files changed

+270
-274
lines changed

21 files changed

+270
-274
lines changed

internals/proxy/middlewares/aliases.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
type AliasMiddleware struct {
16-
Next http.Handler
16+
Next http.Handler
1717
}
1818

1919
func (data AliasMiddleware) Use() http.Handler {
@@ -52,11 +52,11 @@ func (data AliasMiddleware) Use() http.Handler {
5252
keyWithoutPrefix := key[1:]
5353

5454
switch prefix {
55-
case "@":
56-
bodyData[keyWithoutPrefix] = value
57-
modifiedBody = true
58-
case ".":
59-
settings.VARIABLES[keyWithoutPrefix] = value
55+
case "@":
56+
bodyData[keyWithoutPrefix] = value
57+
modifiedBody = true
58+
case ".":
59+
settings.VARIABLES[keyWithoutPrefix] = value
6060
}
6161
}
6262
}
@@ -85,7 +85,7 @@ func (data AliasMiddleware) Use() http.Handler {
8585
})
8686
}
8787

88-
func processDataAliases(aliases map[string][]middlewareTypes.DataAlias, data map[string]any) (map[string]any) {
88+
func processDataAliases(aliases map[string][]middlewareTypes.DataAlias, data map[string]any) map[string]any {
8989
aliasData := map[string]any{}
9090

9191
for key, alias := range aliases {

internals/proxy/middlewares/auth.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
type AuthMiddleware struct {
15-
Next http.Handler
15+
Next http.Handler
1616
}
1717

1818
func getAuthType(str string) authType {
@@ -26,7 +26,7 @@ func getAuthType(str string) authType {
2626
}
2727
}
2828

29-
func isValidToken(tokens []string, match string) (bool) {
29+
func isValidToken(tokens []string, match string) bool {
3030
return slices.Contains(tokens, match)
3131
}
3232

@@ -57,26 +57,26 @@ func (data AuthMiddleware) Use() http.Handler {
5757
authToken = authBody[1]
5858

5959
switch authType {
60-
case Bearer:
61-
if isValidToken(tokens, authToken) {
62-
success = true
63-
}
60+
case Bearer:
61+
if isValidToken(tokens, authToken) {
62+
success = true
63+
}
6464

65-
case Basic:
66-
basicAuthBody, err := base64.StdEncoding.DecodeString(authToken)
65+
case Basic:
66+
basicAuthBody, err := base64.StdEncoding.DecodeString(authToken)
6767

68-
if err != nil {
69-
log.Error("Could not decode Basic Auth Payload: ", err.Error())
70-
}
68+
if err != nil {
69+
log.Error("Could not decode Basic Auth Payload: ", err.Error())
70+
}
7171

72-
basicAuth := string(basicAuthBody)
73-
basicAuthParams := strings.Split(basicAuth, ":")
72+
basicAuth := string(basicAuthBody)
73+
basicAuthParams := strings.Split(basicAuth, ":")
7474

75-
user := "api"
75+
user := "api"
7676

77-
if basicAuthParams[0] == user && isValidToken(tokens, basicAuthParams[1]) {
78-
success = true
79-
}
77+
if basicAuthParams[0] == user && isValidToken(tokens, basicAuthParams[1]) {
78+
success = true
79+
}
8080
}
8181

8282
} else if authQuery != "" {

internals/proxy/middlewares/common.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
type Context struct {
10-
Next http.Handler
10+
Next http.Handler
1111
}
1212

1313
type authType string
@@ -24,21 +24,21 @@ type contextKey string
2424
const tokenKey contextKey = "token"
2525

2626
func getSettingsByReq(req *http.Request) *config.SETTING_ {
27-
token, ok := req.Context().Value(tokenKey).(string)
27+
token, ok := req.Context().Value(tokenKey).(string)
2828

29-
if !ok {
30-
token = "*"
31-
}
29+
if !ok {
30+
token = "*"
31+
}
3232

33-
return getSettings(token)
33+
return getSettings(token)
3434
}
3535

3636
func getSettings(token string) *config.SETTING_ {
37-
settings, exists := config.ENV.SETTINGS[token]
37+
settings, exists := config.ENV.SETTINGS[token]
3838

39-
if !exists || settings == nil {
40-
settings = config.ENV.SETTINGS["*"]
41-
}
39+
if !exists || settings == nil {
40+
settings = config.ENV.SETTINGS["*"]
41+
}
4242

43-
return settings
44-
}
43+
return settings
44+
}

internals/proxy/middlewares/endpoints.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
type EndpointsMiddleware struct {
12-
Next http.Handler
12+
Next http.Handler
1313
}
1414

1515
func (data EndpointsMiddleware) Use() http.Handler {
@@ -60,7 +60,7 @@ func isBlocked(endpoint string, allowed []string, blocked []string) bool {
6060
}
6161

6262
// Allow all except explicitly Blocked
63-
if len(allowed) == 0 && len(blocked) != 0{
63+
if len(allowed) == 0 && len(blocked) != 0 {
6464
return isExplicitlyBlocked
6565
}
6666

@@ -71,4 +71,4 @@ func isBlocked(endpoint string, allowed []string, blocked []string) bool {
7171

7272
// Block all
7373
return true
74-
}
74+
}

internals/proxy/middlewares/log.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (data LogMiddleware) Use() http.Handler {
1515

1616
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
1717
log.Info(req.Method, " ", req.URL.Path, " ", req.URL.RawQuery)
18-
18+
1919
next.ServeHTTP(w, req)
2020
})
21-
}
21+
}

internals/proxy/middlewares/message.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
type MessageMiddleware struct {
14-
Next http.Handler
14+
Next http.Handler
1515
}
1616

1717
func (data MessageMiddleware) Use() http.Handler {
@@ -31,7 +31,6 @@ func (data MessageMiddleware) Use() http.Handler {
3131
messageTemplate = getSettings("*").MESSAGE_TEMPLATE
3232
}
3333

34-
3534
body, err := request.GetReqBody(w, req)
3635

3736
if err != nil {

internals/proxy/middlewares/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ func (data ServeMiddleware) Use() http.Handler {
2020
mux.Handle("/", data.Next)
2121

2222
return mux
23-
}
23+
}

internals/proxy/middlewares/template.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
type TemplateMiddleware struct {
21-
Next http.Handler
21+
Next http.Handler
2222
}
2323

2424
func (data TemplateMiddleware) Use() http.Handler {
@@ -137,11 +137,11 @@ func normalizeData(fromPrefix, toPrefix string, data map[string]any) (map[string
137137
return data, nil
138138
}
139139

140-
func prefixData(prefix string, data map[string]any) (map[string]any) {
140+
func prefixData(prefix string, data map[string]any) map[string]any {
141141
res := map[string]any{}
142142

143143
for key, value := range data {
144-
res[prefix + key] = value
144+
res[prefix+key] = value
145145
}
146146

147147
return res
@@ -192,7 +192,7 @@ func TemplateBody(body map[string]any, headers map[string]any, VARIABLES map[str
192192
prefixedHeaders := prefixData("header_key_", headers)
193193

194194
variables := VARIABLES
195-
195+
196196
maps.Copy(variables, prefixedBody)
197197
maps.Copy(variables, prefixedHeaders)
198198

internals/proxy/middlewares/types/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
package middlewareTypes
55

66
type DataAlias struct {
7-
Alias string `koanf:"alias"`
8-
Score int `koanf:"score"`
7+
Alias string `koanf:"alias"`
8+
Score int `koanf:"score"`
99
}

internals/proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ func Create(targetUrl string) *httputil.ReverseProxy {
1111
proxy := httputil.NewSingleHostReverseProxy(url)
1212

1313
return proxy
14-
}
14+
}

0 commit comments

Comments
 (0)