mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
19 lines
370 B
Go
19 lines
370 B
Go
package response
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"github.com/labstack/echo/v4"
|
||
|
|
)
|
||
|
|
|
||
|
|
func RedirectOnError(target string) echo.HTTPErrorHandler {
|
||
|
|
return func(err error, c echo.Context) {
|
||
|
|
if he, ok := err.(*echo.HTTPError); ok {
|
||
|
|
// Log the error if needed
|
||
|
|
c.Logger().Errorf("Error: %v", he.Message)
|
||
|
|
}
|
||
|
|
// Redirect to main site
|
||
|
|
c.Redirect(http.StatusFound, target)
|
||
|
|
}
|
||
|
|
}
|