微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Loft Server 单线程HTTP服务器

程序名称:Loft Server

授权协议: 未知

操作系统: 跨平台

开发语言: Scala

Loft Server 介绍

loft 是一个用 Scala 开发的单线程 HTTP 服务器,示例代码如下:

object ExampleHandler extends RequestHandler {

  @Asynchronous  
  def get() {  
    val http = AsyncHTTPClient()  
    reset {  
      val id = redis get("roger_schildmeijer");   //async call  
      val result = http fetch("http://127.0.0.1:8080/" + id); //async call  
      write(result)  
      finish   
    }  
  }

  val application = Application(Map("/".r -> this))

  def main(args: Array[String]) {  
    val httpServer = HTTPServer(application)  
    httpServer listen(8888)  
    IOLoop start  
  }

}

Loft Server 官网

https://github.com/rschildmeijer/loft

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐