loft是一个用Scala开发的单线程HTTP服务器,示例代码如下:
objectExampleHandlerextendsRequestHandler{ @Asynchronous defget(){ valhttp=AsyncHTTPClient() reset{ valid=redisget("roger_schildmeijer"); //asynccall valresult=httpfetch("https://127.0.0.1:8080/"+id);//asynccall write(result) finish } } valapplication=Application(Map("/".r->this)) defmain(args:Array[String]){ valhttpServer=HTTPServer(application) httpServerlisten(8888) IOLoopstart }}点击空白处退出提示
评论