001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.devtools.tunnel.server; 018 019import java.io.IOException; 020 021import org.springframework.boot.devtools.remote.server.Handler; 022import org.springframework.http.server.ServerHttpRequest; 023import org.springframework.http.server.ServerHttpResponse; 024import org.springframework.util.Assert; 025 026/** 027 * Adapts a {@link HttpTunnelServer} to a {@link Handler}. 028 * 029 * @author Phillip Webb 030 * @since 1.3.0 031 */ 032public class HttpTunnelServerHandler implements Handler { 033 034 private HttpTunnelServer server; 035 036 /** 037 * Create a new {@link HttpTunnelServerHandler} instance. 038 * @param server the server to adapt 039 */ 040 public HttpTunnelServerHandler(HttpTunnelServer server) { 041 Assert.notNull(server, "Server must not be null"); 042 this.server = server; 043 } 044 045 @Override 046 public void handle(ServerHttpRequest request, ServerHttpResponse response) 047 throws IOException { 048 this.server.handle(request, response); 049 } 050 051}