/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.http.server;

import lc.mecha.fabric.HandlerStatus;
import lc.mecha.fabric.MessageReceiver;
import lc.mecha.log.MechaLogger;
import lc.mecha.log.MechaLoggerFactory;

public class NotFoundHandler implements MessageReceiver<HttpTransaction> {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(NotFoundHandler.class);

    @Override
    public HandlerStatus receive(HttpTransaction msg) throws Throwable {
        // Note this doesn't work due to bugs in WebServer improperly configuring jetty
        msg.httpServletResponse.setStatus(404);
        msg.httpServletResponse.setContentType("text/plain");
        msg.httpServletResponse.getOutputStream().print("Not Found");

        return HandlerStatus.BREAK;
    }
}
