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

Commit 8464593

Browse files
authored
Impl #23
Co-authored-by: Katsute <[email protected]>
1 parent d1c667b commit 8464593

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpServerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.kttdevelopment.simplehttpserver;
22

3+
import com.kttdevelopment.simplehttpserver.handler.RootHandler;
34
import com.sun.net.httpserver.*;
45

56
import java.io.IOException;
@@ -108,6 +109,8 @@ public synchronized final HttpContext createContext(final String path){
108109

109110
@Override
110111
public synchronized final HttpContext createContext(final String path, final HttpHandler handler){
112+
if(!getContext(path).equals("/") && handler instanceof RootHandler)
113+
throw new IllegalArgumentException("RootHandler can only be used at the root '/' context");
111114
final HttpContext context = server.createContext(getContext(path),handler);
112115
contexts.put(context,handler);
113116
return context;

0 commit comments

Comments
 (0)