refactor: improve error interceptor
This commit is contained in:
@@ -18,6 +18,7 @@ limitations under the License.
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/jkaninda/goma-gateway/internal/middleware"
|
||||
error_interceptor "github.com/jkaninda/goma-gateway/pkg/error-interceptor"
|
||||
"github.com/jkaninda/goma-gateway/pkg/logger"
|
||||
"github.com/jkaninda/goma-gateway/util"
|
||||
"golang.org/x/oauth2"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
"golang.org/x/oauth2/gitlab"
|
||||
"golang.org/x/oauth2/google"
|
||||
"gopkg.in/yaml.v3"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -180,11 +182,24 @@ func initConfig(configFile string) error {
|
||||
Middlewares: []string{"basic-auth", "api-forbidden-paths"},
|
||||
},
|
||||
{
|
||||
Path: "/",
|
||||
Name: "Hostname and load balancing example",
|
||||
Hosts: []string{"example.com", "example.localhost"},
|
||||
InterceptErrors: []int{404, 405, 500},
|
||||
RateLimit: 60,
|
||||
Path: "/",
|
||||
Name: "Hostname and load balancing example",
|
||||
Hosts: []string{"example.com", "example.localhost"},
|
||||
//InterceptErrors: []int{404, 405, 500},
|
||||
ErrorInterceptor: error_interceptor.ErrorInterceptor{
|
||||
ContentType: applicationJson,
|
||||
Errors: []error_interceptor.Error{
|
||||
{
|
||||
Code: http.StatusUnauthorized,
|
||||
Message: http.StatusText(http.StatusUnauthorized),
|
||||
},
|
||||
{
|
||||
Code: http.StatusInternalServerError,
|
||||
Message: http.StatusText(http.StatusInternalServerError),
|
||||
},
|
||||
},
|
||||
},
|
||||
RateLimit: 60,
|
||||
Backends: []string{
|
||||
"https://example.com",
|
||||
"https://example2.com",
|
||||
|
||||
Reference in New Issue
Block a user