Fix config init

This commit is contained in:
Jonas Kaninda
2024-11-14 18:32:25 +01:00
parent 0905a41941
commit 5e66a634f2
6 changed files with 12 additions and 103 deletions

View File

@@ -19,8 +19,6 @@ package middleware
import (
"encoding/json"
"fmt"
"github.com/jkaninda/goma-gateway/pkg/errorinterceptor"
"net/http"
"slices"
)
@@ -37,27 +35,6 @@ func getRealIP(r *http.Request) string {
func allowedOrigin(origins []string, origin string) bool {
return slices.Contains(origins, origin)
}
func canInterceptError(code int, errors []errorinterceptor.Error) bool {
for _, er := range errors {
if er.Code == code {
return true
}
continue
}
return false
}
func errMessage(code int, errors []errorinterceptor.Error) (string, error) {
for _, er := range errors {
if er.Code == code {
if len(er.Message) != 0 {
return er.Message, nil
}
continue
}
}
return "", fmt.Errorf("%d errors occurred", code)
}
// RespondWithError is a helper function to handle error responses with flexible content type
func RespondWithError(w http.ResponseWriter, statusCode int, logMessage string) {