No description
Find a file
2025-07-16 15:16:54 +07:00
.github Update test.yml 2025-07-09 08:34:05 +07:00
src/fastcgi respond can send more data than 64k 2025-07-15 20:46:52 -07:00
tests some minor tweaks 2020-06-03 23:31:44 +07:00
.gitignore Initial commit 2019-11-01 01:55:59 +07:00
fastcgi.nimble Update fastcgi.nimble 2025-07-16 15:16:54 +07:00
LICENSE Initial commit 2019-11-01 01:55:59 +07:00
README.md Update README.md 2023-10-12 20:10:20 +07:00

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://paypal.me/ba0f3