iris icon indicating copy to clipboard operation
iris copied to clipboard

suggest: give BeginRequest a return value

Open tfzxyinhao opened this issue 9 years ago • 3 comments

#Documentation for the iris project can be found at https://github.com/kataras/iris#-learn. iris version: 8.5.0 go version: 1.9.1 beta

In my case have multi-role users, I need to check user role in BeginRequest, I want to return response if role check fail so give BeginRequest a return value can let me know this operation result.

tfzxyinhao avatar Oct 10 '17 06:10 tfzxyinhao

I think verify user permissions should at middleware, not at BeginRequest handler

motecshine avatar Oct 10 '17 06:10 motecshine

for multi-role, a different role can visit different controller, so I need to check it in BeginRequest handler

tfzxyinhao avatar Oct 10 '17 06:10 tfzxyinhao

@tfzxyinhao You can do that with the current implementation. BeginRequest can also terminate the request skipping the method function: https://github.com/kataras/iris/blob/master/mvc/activator/activator.go#L142

You have to write ctx.StopExecution() inside your BeginRequest, easy enough, no need to change the public API for that thing, BeginRequest should be fast.

hiveminded avatar Oct 10 '17 11:10 hiveminded