Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created June 19, 2011 11:56
Show Gist options
  • Save markhibberd/1034177 to your computer and use it in GitHub Desktop.
Save markhibberd/1034177 to your computer and use it in GitHub Desktop.
Foil configuration demo
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)
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