-
-
Save skurfuerst/f7621b3a0140083aee18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ratpack.handling.Context | |
import ratpack.handling.Handler | |
import ratpack.server.PublicAddress | |
import ratpack.session.Session | |
import ratpack.session.SessionManager | |
import ratpack.session.internal.RequestSessionManager | |
/** | |
* Created by sebastian on 13.07.14. | |
*/ | |
class NameBasedHostingHandler implements Handler { | |
private final Handler handler | |
def NameBasedHostingHandler(Handler handler) { | |
this.handler = handler | |
} | |
@Override | |
void handle(Context context) throws Exception { | |
// START of TRY 1 | |
context.getRequest().registerLazy(PublicAddress.class, new ratpack.func.Factory<PublicAddress>() { | |
public PublicAddress create() { | |
// is not called. | |
return new NameBasedPublicAddress() | |
} | |
}); | |
context.insert(handler) | |
// END of TRY 1 | |
// START of TRY 2 | |
context.getRequest().register(PublicAddress.class, new NameBasedPublicAddress()) | |
handler.handle(context); | |
// END of TRY 2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment