Commit b7f0bc09 authored by TheBeggs's avatar TheBeggs

Add new Markdown result type

parent 5a1cfe19
package ic.doc.web;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
public class MarkdownResultPage implements Page {
private final String query;
private final String answer;
public MarkdownResultPage(String query, String answer) {
this.query = query;
this.answer = answer;
}
public void writeTo(HttpServletResponse resp) throws IOException {
resp.setContentType("text/markdown");
resp.setHeader("Content-Disposition", "attachment;filename=result.md");
PrintWriter writer = resp.getWriter();
// Content
if (answer == null || answer.isEmpty()) {
writer.println("# Sorry");
writer.println("Sorry, we didn't understand: *" + query + "*");
writer.println("");
} else {
writer.println("# " + query);
writer.println(answer);
}
}
}
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