Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 1426e12

Browse files
committed
Create TemporaryHandler.java
1 parent a4c211f commit 1426e12

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.kttdevelopment.simplehttpserver.handler;
2+
3+
import com.sun.net.httpserver.HttpExchange;
4+
import com.sun.net.httpserver.HttpHandler;
5+
6+
import java.io.IOException;
7+
8+
public class TemporaryHandler implements HttpHandler {
9+
10+
private final HttpHandler handler;
11+
12+
public TemporaryHandler(final HttpHandler handler){
13+
this.handler = handler;
14+
}
15+
16+
public TemporaryHandler(final HttpHandler handler, final long maxTime){
17+
this.handler = handler;
18+
}
19+
20+
@Override
21+
public final void handle(final HttpExchange exchange) throws IOException{
22+
handler.handle(exchange);
23+
exchange.getHttpContext().getServer().removeContext(exchange.getHttpContext());
24+
}
25+
26+
}

0 commit comments

Comments
 (0)