Created
June 19, 2011 11:56
-
-
Save markhibberd/1034177 to your computer and use it in GitHub Desktop.
Foil configuration demo
This file contains hidden or 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 io.mth.foil._ | |
import javax.servlet.http._ | |
class DemoServlet extends HttpServlet { | |
override def service(req: HttpServletRequest, resp: HttpServletResponse) = { | |
val path = req.getPathInfo | |
val writer = resp.getWriter | |
writer.println("hello from " + path) | |
} | |
} | |
val config = compound(List( | |
servlet("/", "/*", new DemoServlet), | |
path("/static", "static") | |
)) | |
val foil = Foil("demp", 10080, config) | |
runfoil(foil) |
This file contains hidden or 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 io.mth.foil.j.*; | |
import javax.servlet.http.*; | |
import java.io.*; | |
public class JavaDemo { | |
private static final Foils f = new DefaultFoils(); | |
private static final Configs c = new DefaultConfigs(); | |
public static class DemoServlet extends HttpServlet { | |
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { | |
String path = req.getPathInfo(); | |
PrintWriter writer = resp.getWriter(); | |
writer.println("hello from " + path); | |
} | |
} | |
public static void main(String[] args) { | |
Config config = c.compound( | |
c.servlet("/", "/*", new DemoServlet()), | |
c.path("/static", "static") | |
); | |
Foil foil = f.nu("demo", 10080, config); | |
foil.run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment