fastcgi.nim

2025-12-07 0 312

FastCGI

FastCGI library for Nim. Server library will coming soon

Installation

nimble  install fastcgi

Usage

FastCGI Server

import fastcgi/server, asyncdispatch

type
  SimpleHandler* = ref object of RequestHandler

method process*(h: SimpleHandler, req: Request) {.async.} =
  await req.respond(\"Hello from simple FastCGI request handler\")

let s = newAsyncFCGIServer()
s.addHandler(\"/fcgi/simple\", new SimpleHandler)
waitFor s.serve(Port(9000))

FastCGI Client

import fastcgi/client

# create new instance
let client = newFCGICLient(\"127.0.0.1\", 9000)
# set params
client.setParam(\"SERVER_SOFTWARE\", \"fastcgi.nim/0.1.0\")
client.setParams({
  \"SERVER_PORT\": \"80\",
  \"SERVER_ADDR\": \"127.0.0.1\",
  \"SCRIPT_FILENAME\": \"/index.php\",
  \"REQUEST_METHOD\": \"POST\"
})
# connect to fastcgi server on port 9000
client.connect()
# send stdin payload
echo client.sendRequest(\"{\'name\':\'John\', \'age\':30, \'car\':null}\")
# close connection
client.close()

Donate

Buy me some beer https://p*ayp*a*l.me/ba0f3

下载源码

通过命令行克隆项目:

git clone https://github.com/ba0f3/fastcgi.nim.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

左子网 开发教程 fastcgi.nim https://www.zuozi.net/31335.html

Member
下一篇: Member
常见问题

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务