Multi tenand app with rewrite

Splash Forums Rewrite Users Multi tenand app with rewrite

This topic contains 5 replies, has 2 voices, and was last updated by  Christian Kaltepoth 7 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #25795


    I would like to write a rule that enables me to make my application multi tenand

    basically I would like to introduce a path variable “organization” as the first path segment and add it as parameter
    My first attempt is this:


    1. It does not consider parameters at all
    2. It does not accept deeper paths with multiple /../../

    What must I do to “join” organisation as a Get paramenter for any possible url?

    Thank you!



    A few things to note here:

    * you won’t need the params parameter at all, as query parameter are automatically preserved.
    * parameters are automatically turned into query parameters. So you don’t need organisaion in the to() part at all.
    * By default parameters only match a single path segment. But you can change the regular expression that is used for this.

    So you could try this one:



    Thank you Christian,
    It works.

    now I have a legacy code which redirects me to /WEB-INF/**

    I do not understand the fluid interface very well
    for example I try to

    .addRule().when(Path.matches("/WEB-INF/.*")).perform(Log.message(Level.INFO, "web-inf"))
    			   .perform(Log.message(Level.INFO, "Forward to /{path}?organisation={organisation}"))

    and it never hits the first rule

    how could I exclude everything that goes to WEB-INF from my multitenant join rule?


    You could use this rule which will basically abort evaluating other rules if the path matches:

    .when( Path.matches( "/WEB-INF/{whatever}" ) )
    .perform( Lifecycle.proceed() )
    .where( "whatever" ).matches( ".*" )

    Another option would be to modify the regular expression for the organisation parameter so that WEB-INF doesn’t match it any more.



    I came to this solution with Lifecycle.handled():

    .perform(Log.message(Level.INFO, "{path}").and(Lifecycle.handled()))

    What exactly is the difference to Lifecycle.proceed() ?



    Oh, sorry. Yeah, handled() is correct as this one prevents that further rules are evaluated. If you use proceed() other rules will be evaluated which will lead to the problems you described above. Sorry, I mixed them up. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.