private ContextPathHandler getCorrespondingHandler( SocketChannel socketChannel, MessageStat messageStat) { ContextPathHandler contextPathHandler = contextPathMap.get(messageStat.getHeader().get(RequestHeaderEntry.CONTEXT_PATH)); return contextPathHandler != null ? contextPathHandler : contextPathMap.get(messageStat.getContextPathWithoutQuery()); }
/** * Handles request corresponding to the specified context paths. * * @param socketChannel Used to communicate between client and server. * @param messageStat Holds necessary request data to act on the context paths. */ private void handle(SocketChannel socketChannel, MessageStat messageStat) { log.debug("stat: " + messageStat.getHeader().get(RequestHeaderEntry.CONTEXT_PATH)); ContextPathHandler contextPathHandler = getCorrespondingHandler(socketChannel, messageStat); if (contextPathHandler != null) { contextPathHandler.handle(socketChannel, messageStat); } else { // TODO favicon.ico handler is needed if (messageStat.getContextPathWithoutQuery().equals("/favicon.ico")) { log.warn("currently favicon is not supported. will be done soon."); } else { contextPathMap.get("NotFound").handle(socketChannel, messageStat); } } }