com.hotels.styx.api.http.handlers.NotFoundHandler Maven / Gradle / Ivy
/*
Copyright (C) 2013-2018 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.hotels.styx.api.http.handlers;
import com.hotels.styx.api.HttpHandler;
import com.hotels.styx.api.HttpRequest;
import com.hotels.styx.api.HttpResponse;
import static com.hotels.styx.api.HttpResponse.Builder.response;
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
/**
* Returns a 404 Not Found response.
*/
public class NotFoundHandler extends BaseHttpHandler {
public static final HttpHandler NOT_FOUND_HANDLER = new NotFoundHandler();
private static final String NOT_FOUND_MESSAGE = "\n"
+ "\n"
+ "\n"
+ " \n"
+ " \n"
+ " Error 404 (Not Found)!!1 \n"
+ " 404. That’s an error.\n"
+ "
The requested URL was not found on this server.\n";
@Override
public HttpResponse doHandle(HttpRequest request) {
return response(NOT_FOUND)
.body(NOT_FOUND_MESSAGE)
.build();
}
}