• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

EvandroLG/pegasus.lua: Pegasus.lua is an http server to work with web applicatio ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

EvandroLG/pegasus.lua

开源软件地址(OpenSource Url):

https://github.com/EvandroLG/pegasus.lua

开源编程语言(OpenSource Language):

Lua 97.6%

开源软件介绍(OpenSource Introduction):

pegasus.lua

An http server to work with web applications written in Lua language check the site.

Build Status HuBoard badge Gitter

Installation

To install Pegasus.lua, run:

$ luarocks install pegasus

How does it work?

Follow an example:

local pegasus = require 'pegasus'

local server = pegasus:new({
  port='9090',
  location='example/root'
})

server:start(function (request, response)
  print "It's running..."
end)

Features

  • Compatible with Linux, Mac and Windows systems
  • Easy API
  • Support Lua >= 5.1
  • Native support for HTTP Streaming, aka chunked responses. Check how it works.
  • Native plugin to compress responses using the "gzip" method

API

Parameters

  • host:string Host address where the application will run. By default it uses localhost
  • port:string The port where the application will run. By default it's 9090
  • location:string Path used by Pegasus to search for the files. By default it's the root
  • plugins:table List with plugins
  • timeout:number It's a timeout for estabilishing a connection with the server

Request

Properties

  • path:string A string with the request path
  • headers:table A table with all the headers data
  • method:function The output is the request method as a string ('GET', 'POST', etc)
  • querystring:string It returns a dictionary with all the GET parameters
  • ip:string It returns the client's ip
  • port:number It returns the port where Pegasus is running

Response

Methods

  • addHeader(string:key, string:value) Adds a new header
  • addHeaders(table:headers) It adds news headers
  • statusCode(number:statusCode, string:statusMessage) It adds a Status Code
  • contentType(string:value) Adds a value to Content-Type field
  • write(string:body) It creates the body with the value passed as parameter
  • writeFile(string:file) It creates the body with the content of the file passed as parameter
  • post():table It returns a dictionary with all the POST parameters
local pegasus = require 'pegasus'

local server = pegasus:new({ port='9090' })

server:start(function (req, rep)
  rep:addHeader('Date', 'Mon, 15 Jun 2015 14:24:53 GMT'):write('hello pegasus world!')
end)

Native Plugin

  • pegasus.compress
local Pegasus = require 'pegasus'
local Compress = require 'pegasus.compress'

local server = Pegasus:new({
  plugins = { Compress:new() }
})

server:start()

Contributing

Install Dependencies

$ make install_dependencies

Running tests

$ make unit_test



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap