view src/luan/modules/http/impl/NotFound.java @ 1166:7ef40e1923b7

add back Thread.global allow metatables to have metatables
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 08 Feb 2018 02:22:51 -0700
parents 4beabb087be6
children 7e6f28c769a1
line wrap: on
line source

package luan.modules.http.impl;

import luan.webserver.Request;
import luan.webserver.Response;
import luan.webserver.Handler;


public class NotFound implements Handler {
	private final Handler handler;

	public NotFound(Handler handler) {
		this.handler = handler;
	}

	@Override public Response handle(Request request) {
		Response response = handler.handle(request);
		if( response == null ) {
			String path = request.path;
			try {
				request.path = "/not_found";
				response = handler.handle(request);
			} finally {
				request.path = path;
			}
		}
		return response;
	}

}