@@ -0,0 +1,1327 @@
+/*%0A * Copyright 2014 SATO taichi%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0Apackage example;%0A%0Aimport java.util.Optional;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0Aimport ninja.siden.App;%0A%0A/**%0A * @author taichi%0A */%0Apublic class URLShortener %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09App app = new App();%0A%09%09ConcurrentHashMap%3CString, String%3E map = new ConcurrentHashMap%3C%3E();%0A%09%09app.post(%22/%22, (req, res) -%3E %7B%0A%09%09%09Optional%3CString%3E opt = req.forms().keySet().stream().findFirst();%0A%09%09%09return opt.map(s -%3E %7B%0A%09%09%09%09String k = Integer.toHexString(s.hashCode());%0A%09%09%09%09map.put(k, s);%0A%09%09%09%09return String.format(%22http://%25s/%25s%22,%0A%09%09%09%09%09%09req.raw().getHostAndPort(), k);%0A%09%09%09%7D);%0A%09%09%7D);%0A%0A%09%09app.get(%22/:k%22, (req, res) -%3E req.params(%22k%22).map(key -%3E map.get(key))%0A%09%09%09%09.map(res::redirect).orElse(404));%0A%0A%09%09app.listen();%0A%09%7D%0A%7D%0A

add URLShortener example.