Last active
December 15, 2015 22:30
-
-
Save ilopmar/a55af3346aaa788c632d 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
package com.example | |
import ratpack.guice.Guice | |
import ratpack.server.RatpackServer | |
public class MyApp { | |
public static void main(String[] args) throws Exception { | |
RatpackServer.start { spec -> | |
spec.registry { | |
Guice.registry { r -> | |
r.bind(MyService.class) | |
} | |
} | |
.handlers { chain -> | |
chain.get { ctx -> | |
MyService myService = ctx.get(MyService.class) | |
myService.myMethod() | |
ctx.render("Finished!") | |
} | |
} | |
} | |
} | |
} |
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
package example; | |
import ratpack.guice.Guice; | |
import ratpack.server.RatpackServer; | |
public class MyApp { | |
public static void main(String[] args) throws Exception { | |
RatpackServer.start(spec -> spec | |
.registry(Guice.registry(r -> r | |
.bind(MyService.class) | |
)) | |
.handlers(chain -> chain | |
.get(ctx -> { | |
MyService myService = ctx.get(MyService.class); | |
myService.myMethod(); | |
ctx.render("Finished"); | |
}) | |
)); | |
} | |
} |
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
package com.example | |
class MyService { | |
void myMethod() { | |
System.out.println("calling myMethod"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, just change to