mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
overlap routing: and mvc: allow setting status code from a dependency or a middleware
This commit is contained in:
@@ -63,7 +63,17 @@ func authDependency(ctx iris.Context, session *sessions.Session) Authenticated {
|
||||
if userID == 0 {
|
||||
// If execution was stopped
|
||||
// any controller's method will not be executed at all.
|
||||
ctx.StopWithStatus(iris.StatusUnauthorized)
|
||||
//
|
||||
// Note that, the below will not fire the error to the user:
|
||||
// ctx.StopWithStatus(iris.StatusUnauthorized)
|
||||
// because of the imaginary:
|
||||
// UnauthenticatedUserController.Get() (string, int) {
|
||||
// return "...", iris.StatusOK
|
||||
// }
|
||||
//
|
||||
// OR
|
||||
// If you don't want to set a status code at all:
|
||||
ctx.StopExecution()
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user