New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New controller and routing system ignores global request interceptors #345
Comments
Bug 3) has been fixed. At least it seems so. Anyways I think there needs to be a better handling of interceptors. Whenever I annotate my Controller class with an interceptor and some action method as well both of them should be executed. First should be executed action interceptors, then all class interceptors and then base class interceptors. Thank you |
I think that current implementation works well with your scenario. When a controller method is invoked the interceptors on method are executed and AFTER them the interceptors on class are executed. import ro.pippo.controller.Interceptor;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Interceptor(LoggingHandler.class)
public @interface Logging {
} import ro.pippo.core.route.RouteContext;
import ro.pippo.core.route.RouteHandler;
public class LoggingHandler implements RouteHandler {
@Override
public void handle(RouteContext routeContext) {
System.out.println("LoggingHandler.handle");
routeContext.next(); // <<< IMPORTANT
}
} All interceptors are added in a chain and you can specify in the route handler of the interceptor if you want to call next interceptor or not (according the business logic from interceptor). |
Yes sorry I know I forgot to announce it here :) Anyways please is it possible to get route attributes either from a controller's action or filter ? I mean for a current request. I can get list of routes using findRoutes or searchRoutes but it gets list of routes. I would like to get a specified 1 route that translated a request to a specified action method. |
For now it's not possible but you have this workaround (use a common method for post and get methods): class MyController extends Controller {
@GET
myGetMethod(...) {
commonMethod(...);
}
@PUT
myPutMethod(...) {
commonMethod(...);
}
commonMethod(...) {
// your business
}
} |
Yes that's how I do it now.
…On Sun, Jan 29, 2017 at 1:29 PM, Decebal Suiu ***@***.***> wrote:
Whenever I annotate my action method with more then 1 route annotation for
example @get <https://github.com/GET>("") and @put
<https://github.com/PUT>("") only the first one defined is actualy
enabled and executed.
For now it's not possible but you have this workaround (use a common
method for post and get methods):
class MyController extends Controller {
@get
myGetMethod(...) {
commonMethod(...);
}
@put
myPutMethod(...) {
commonMethod(...);
}
commonMethod(...) {
// your business
}
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#345 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AD9XB9yRkHAnuKoi4zrLDFA5qg8Vn5UBks5rXIYegaJpZM4Lt9To>
.
|
Hey, I have tested new method getRoute() that I call in my Authentication interceptor handler. Any clue ? |
When I print attributes from a controller's action method they are there and my previously set key is there as well. |
Can you share the code from your transformer (or only the part that create the returned value)? |
|
Thanks. I found a possible bug at this line. When I create the virtual route for interceptor I doesn't pass the attributes from controller route and probably your espectation is to have these attributes. |
Well it might be. But still do you think that you need to have to different
routes when practically there just a one ?
I mean logically it would make a sense to return a very same route as you
get from a controller or better route that is filled with same attributes.
…On Sun, Jan 29, 2017 at 11:29 PM, Decebal Suiu ***@***.***> wrote:
Thanks. I found a possible bug at this
<https://github.com/decebals/pippo/blob/master/pippo-controller-parent/pippo-controller/src/main/java/ro/pippo/controller/ControllerRouteHandler.java#L344>
line. When I create the virtual route for interceptor I doesn't pass the
attributes from controller route and probably your espectation is to have
these attributes.
Probably it's a better solution to have a single attribute
__controllerRoute in interceptor that returns the controller route.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#345 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AD9XB8ikHfmrWuaXJt5e5iHC5XLNc0RCks5rXRKygaJpZM4Lt9To>
.
|
@dunsunik I don't know if the interceptor is not enough in your case (without the route transformer). For example you can retrieve in interceptor route handler the controller method (via |
Hey,
No it's ok.
Since your last commit everything seems to be working perfectly !
Thank you
…On Mon, Jan 30, 2017 at 8:34 PM, Decebal Suiu ***@***.***> wrote:
@dunsunik <https://github.com/dunsunik> I don't know if the interceptor
is not enough in your case (without the route transformer). For example you
can retrieve in interceptor route handler the controller method (via
routeContext.getRoute().getAttribute("__controllerMethod")) and check if
ActivationNotRequired annotation is present or not.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#345 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AD9XB4I86-GJbrfl4S6sgEEiZO0Yyne8ks5rXjsqgaJpZM4Lt9To>
.
|
Whenever I annotate my action method with more then 1 route annotation for example @get("") and @put("") only the first one defined is actualy enabled and executed.
I tried to create some basic type of interceptors for example one annotation @justatest that is placed on my controller class and a second one annotation @required that is placed on an action method.
When I annotade my controller class with @justatest and some of my action method with @required only the @required annotation is executed. Both of them should be executed right ?
My application based filters are not executed anymore after using controllers.
In my Application I have defined this filter:
The text was updated successfully, but these errors were encountered: