RaphtersC 语言的 Web 框架

联合创作 · 2023-09-20 17:16

Raphters 是一个C 语言的Web框架,基于 RAPHT 架构模式。包含如下模块:

  • Resources include things served up to clients like a database or API.
  • Actions provide ways to interact with a Resource.
  • Processors transform data.
  • Handlers provide the entry point for a request.
  • Templates render data.

示例代码:

#include "raphters.h"

START_HANDLER (simple, GET, "simple", res, 0, matches) {
    response_add_header(res, "content-type", "text/html");
    response_write(res, "hello world");
} END_HANDLER

START_HANDLER (default_handler, GET, "", res, 0, matches) {
    response_add_header(res, "content-type", "text/html");
    response_write(res, "default page");
} END_HANDLER

int main() {
    add_handler(simple);
    add_handler(default_handler);
    serve_forever();
    return 0;
}
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报