Mercurial Hosting > luan
diff src/goodjava/webserver/handlers/MapHandler.java @ 1402:27efb1fcbcb5
move luan.lib to goodjava
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 17 Sep 2019 01:35:01 -0400 |
parents | src/luan/lib/webserver/handlers/MapHandler.java@643cf1c37723 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/goodjava/webserver/handlers/MapHandler.java Tue Sep 17 01:35:01 2019 -0400 @@ -0,0 +1,20 @@ +package goodjava.webserver.handlers; + +import java.util.Map; +import goodjava.webserver.Handler; +import goodjava.webserver.Request; +import goodjava.webserver.Response; + + +public final class MapHandler implements Handler { + private final Map<String,Handler> map; + + public MapHandler(Map<String,Handler> map) { + this.map = map; + } + + public Response handle(Request request) { + Handler handler = map.get(request.path); + return handler==null ? null : handler.handle(request); + } +}