CPP FastCGI

其他类别 2025-07-28

cpp-fastcgi

该项目的目的是创建功能强大的C ++ FastCGI库,其中每个请求都在线程中运行。

守护程序示例

# include < CppSystemRT.hpp >
# include < CppFastCGI.hpp >

using namespace CppFastCGI ;

class DebugRequest : public Request {
public:
	DebugRequest (RequestInfo* requestInfo): Request(requestInfo) {}

protected:	
	void run () {
		print ( " Content-type: text/html; charset=utf-8 \r\n\r\n " );
		print ( " <html><head><title>Debug Request</title></head><body> " );
		for ( auto & param : requestInfo-> params ) {
			print (param. first + " = " + param. second + " <br> \n " );
		}
		print ( " </body></html> " );
		end ( 0 );
	}
};

int main ( int argc, char * argv[]) {
	RequestHandler requestHandler;
	requestHandler. registerPath <DebugRequest>( " ^/debug " , RequestPath::RegexMatch);
	
	return CppSystemRT::Daemon::exec<Server>( " 127.0.0.1 " , " 9000 " , requestHandler);
}
下载源码

通过命令行克隆项目:

git clone https://github.com/XamanSoft/CPP-FastCGI.git