1
0
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:
Gerasimos (Makis) Maropoulos
2020-08-28 04:11:56 +03:00
parent 933534574a
commit a6ec94e1a6
10 changed files with 181 additions and 63 deletions

View File

@@ -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
}