1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 11:27:06 +00:00

Add Context.SetUser and Context.User methods

relative to: https://github.com/iris-contrib/middleware/issues/63
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-10-12 15:52:53 +03:00
parent dfe27567ae
commit 8e51a296b9
7 changed files with 242 additions and 19 deletions

View File

@@ -51,11 +51,12 @@ func main() {
}
func h(ctx iris.Context) {
username, password, _ := ctx.Request().BasicAuth()
// username, password, _ := ctx.Request().BasicAuth()
// third parameter it will be always true because the middleware
// makes sure for that, otherwise this handler will not be executed.
ctx.Writef("%s %s:%s", ctx.Path(), username, password)
// OR:
user := ctx.User()
ctx.Writef("%s %s:%s", ctx.Path(), user.GetUsername(), user.GetPassword())
}
func logout(ctx iris.Context) {