Fix config init
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user