Commit 73985171 authored by ajb3118's avatar ajb3118

Choose result format based on input parameter

parent 4fb86b26
Pipeline #112274 passed with stages
in 17 seconds
......@@ -2,6 +2,7 @@ package ic.doc;
import ic.doc.web.HTMLResultPage;
import ic.doc.web.IndexPage;
import ic.doc.web.MarkdownResultPage;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
......@@ -27,8 +28,14 @@ public class WebServer {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String query = req.getParameter("q");
String resultFormat = req.getParameter("format");
if (query == null) {
new IndexPage().writeTo(resp);
} else if (resultFormat.toLowerCase().equals("markdown")) {
new MarkdownResultPage(query, new QueryProcessor().process(query)).writeTo(resp);
} else if (resultFormat.toLowerCase().equals("pdf")) {
// TODO: Implement
// new PDFResultPage(query, new QueryProcessor().process(query)).writeTo(resp);
} else {
new HTMLResultPage(query, new QueryProcessor().process(query)).writeTo(resp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment