package com.stubbornjava.examples.undertow.contenttypes;

import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;

public class ContentTypeHandlers {
    private static final String fileName = "helloworld.txt";

    // {{start:text}}
    // @WhereAreAllMyAnnotations??
    // @DecoupledLogicFromRoutingIsNice!
    public static void helloWorldText(HttpServerExchange exchange) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
        exchange.getResponseSender().send("Hello World");
    }
    // {{end:text}}

    // {{start:html}}
    public static void helloWorldHtml(HttpServerExchange exchange) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
        exchange.getResponseSender().send("<h1>Hello World</h1>");
    }
    // {{start:html}}

    // {{start:file}}
    public static void helloWorldFileDownload(HttpServerExchange exchange) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream");
        exchange.getResponseHeaders().put(Headers.CONTENT_DISPOSITION, "inline; filename=\"" + fileName + "\"");
        exchange.getResponseSender().send("Hello World");
    }
    // {{end:file}}

    // {{start:json}}
    public static void helloWorldJson(HttpServerExchange exchange) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json");
        exchange.getResponseSender().send("{\"message\": \"Hello World\"}");
    }
    // {{end:json}}
}

@@ -802,37 +802,35 @@
 %0A    %7D%0A    // %7B%7B
-start
+end
 :html%7D%7D%0A%0A    // 

Fix typo