All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.geektool.http.server.handler.ActionHandler Maven / Gradle / Ivy

There is a newer version: 0.0.9
Show newest version
package cn.geektool.http.server.handler;

import cn.geektool.http.server.HttpServerRequest;
import cn.geektool.http.server.HttpServerResponse;
import cn.geektool.http.server.action.Action;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

import java.io.IOException;

/**
 * Action处理器,用于将HttpHandler转换为Action形式
 *
 * @author looly
 * @since 5.2.6
 */
public class ActionHandler implements HttpHandler {

	private final Action action;

	/**
	 * 构造
	 *
	 * @param action Action
	 */
	public ActionHandler(Action action) {
		this.action = action;
	}

	@Override
	public void handle(HttpExchange httpExchange) throws IOException {
		action.doAction(
				new HttpServerRequest(httpExchange),
				new HttpServerResponse(httpExchange)
		);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy