{"id":41379855,"url":"https://github.com/netcorelink/libchttpx","last_synced_at":"2026-01-23T10:52:48.255Z","repository":{"id":331701715,"uuid":"1128541539","full_name":"netcorelink/libchttpx","owner":"netcorelink","description":"A powerful, cross-platform HTTP server library in C/C++ for building full-featured web servers.","archived":false,"fork":false,"pushed_at":"2026-01-18T14:43:29.000Z","size":823,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-18T22:07:26.767Z","etag":null,"topics":["c","cpp","http","netcorelink"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netcorelink.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-05T19:44:57.000Z","updated_at":"2026-01-18T14:43:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/netcorelink/libchttpx","commit_stats":null,"previous_names":["netcorelink/libchttpx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netcorelink/libchttpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorelink%2Flibchttpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorelink%2Flibchttpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorelink%2Flibchttpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorelink%2Flibchttpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netcorelink","download_url":"https://codeload.github.com/netcorelink/libchttpx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorelink%2Flibchttpx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28689076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","http","netcorelink"],"created_at":"2026-01-23T10:52:47.718Z","updated_at":"2026-01-23T10:52:48.247Z","avatar_url":"https://github.com/netcorelink.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"golangci-lint logo\" src=\"https://avatars.githubusercontent.com/u/252895549?s=400\u0026u=6c747c431c2844620af7772fcd716ef423a6ab1d\u0026v=4\" height=\"150\" /\u003e\n  \u003ch3 align=\"center\"\u003enetcorelink/libchttpx\u003c/h3\u003e\n  \u003cp align=\"center\"\u003eA powerful, cross-platform HTTP server library in C/C++ for building full-featured web servers\u003c/p\u003e\n\u003c/p\u003e\n\n---\n\n`netcorelink/libchttpx` a powerful, cross-platform HTTP server library in C/C++ for building full-featured web servers.\n\n## Linux\n\n```bash\ncurl -s https://raw.githubusercontent.com/netcorelink/libchttpx/main/scripts/install.sh | sudo sh\n```\n\n## Windows\n\n```powershell\niwr https://raw.githubusercontent.com/netcorelink/libchttpx/main/scripts/install.ps1 -UseBasicParsing | iex\n```\n\n---\n\n\u003cp align=\"center\"\u003e\u003ch1 align=\"center\"\u003eDocumentation\u003c/h1\u003e\u003c/p\u003e\n\n### Initial http server\n\n```c\n#include \u003clibchttpx/libchttpx.h\u003e\n\nint main()\n{\n  chttpx_serv_t serv = {0};\n\n  if (cHTTPX_Init(\u0026serv, 80) != 0) {\n    printf(\"Failed to start server\\n\");\n    return 1;\n  }\n\n  // cores\n  // middlewares\n  // routes\n\n  /* At the very end, to start listening to incoming requests from users. */\n  cHTTPX_Listen();\n}\n```\n\n### Server timeouts settings\n\n```c\n/* Timeouts */\nserv.read_timeout_sec = 300;\nserv.write_timeout_sec = 300;\nserv.idle_timeout_sec = 90;\n```\n\n### CORS Settings\n\n`origins` – Array of allowed origin strings (e.g. \"https://example.com\"). Each origin must match exactly the value of the \"Origin\" header.\n\n`origins_count` – Number of elements in the origins array.\n\n`methods` – Comma-separated list of allowed HTTP methods. If NULL, defaults to: \"GET, POST, PUT, DELETE, OPTIONS\".\n\n`headers` – Comma-separated list of allowed request headers. If NULL, defaults to: \"Content-Type\".\n\n```c\n/* Cors */\nconst char *allowed_origins[] = {\n  \"https://exmaple.ru\",\n  \"http://localhost:8080\",\n};\n\ncHTTPX_Cors(allowed_origins, cHTTPX_ARRAY_LEN(allowed_origins), NULL, \"Accept-Language, Auth\");\n```\n\n### Middlewares\n\nExample: Middleware for checking the authenticated user.\n\n```c\nchttpx_middleware_result_t auth_middleware(chttpx_request_t *req, chttpx_response_t *res) {\n  const char *token = cHTTPX_Header(req, \"Auth-Token\");\n\n  if (!token) {\n    *res = cHTTPX_ResJson(cHTTPX_StatusUnauthorized, \"{\\\"error\\\": \\\"unauthorized\\\"}\");\n    return out;\n  }\n\n  return next;\n}\n```\n\nMiddlewares are connected `before cHTTPX_Route`.\n\n```c\ncHTTPX_MiddlewareUse(auth_middleware);\n```\n\n### Routes\n\n`method` – HTTP method string, e.g., \"GET\", \"POST\".\n\n`path` – URL path to match, e.g., \"/users\".\n\n`handler` – Function pointer to handle the request. The handler should return httpx_response_t. This allows the server to call the appropriate function when a matching request is received.\n\n```c\ncHTTPX_Route(\"GET\", \"/\", home_index);\ncHTTPX_Route(\"GET\", \"/users/{uuid}/{org}\", get_user); // ?org=netcorelink\ncHTTPX_Route(\"POST\", \"/users\", create_user);\n```\n\n### Handlers\n\nHTML page return.\n\n```c\nvoid home_index(chttpx_request_t *req, chttpx_response_t *res) {\n  *res = cHTTPX_ResHtml(cHTTPX_StatusOK, \"\u003ch1\u003eThis is home page!\u003c/h1\u003e\");\n}\n```\n\n### Http Response\n\nReturn Json response\n\n```c\nreturn cHTTPX_ResJson(cHTTPX_StatusOK, \"{\\\"message\\\": {\\\"uuid\\\": \\\"%s\\\", \\\"page\\\": \\\"%s\\\"}}\", uuid, page);\n```\n\nReturn Html response\nReturn Media response\n\n\u003c!-- ### Http Request --\u003e\n\n### Parsing JSON fields\n\n```c\ntypedef struct {\n  char *uuid;\n  char *password;\n  int is_admin;\n} user_t;\n\nchttpx_response_t create_user(chttpx_request_t *req) {\n  user_t user = {0};\n\n  chttpx_validation_t fields[] = {\n    chttpx_validation_str(\"uuid\", \u0026user.uuid, true, 0, 36, VALIDATOR_NONE),\n    chttpx_validation_str(\"password\", \u0026user.password, true, 6, 16, VALIDATOR_NONE),\n    chttpx_validation_bool(\"is_admin\", \u0026user.is_admin, false),\n  };\n\n  if (!cHTTPX_Parse(req, fields, cHTTPX_ARRAY_LEN(fields), \"en\")) {\n    *res = cHTTPX_ResJson(cHTTPX_StatusBadRequest, \"{\\\"error\\\": \\\"%s\\\"}\", req-\u003eerror_msg);\n    goto cleanup;\n  }\n\n  /* ... */\n}\n```\n\n\u003e When working with cHTTPX_Parse, you need to refer to `req-\u003eerror_msg`.\n\n### Validations fields\n\nValidates an array of `cHTTPX_FieldValidation` structures.\n\nThis function ensures that `required` fields are present, `string lengths` are within `limits`,\nand basic validation for integers and boolean fields is performed.\n\n\u003e When working with cHTTPX_Validate, you need to refer to `req-\u003eerror_msg`.\n\n```c\nif (!cHTTPX_Validate(req, fields, cHTTPX_ARRAY_LEN(fields), \"en\")) {\n  *res = cHTTPX_ResJson(cHTTPX_StatusBadRequest, \"{\\\"error\\\": \\\"%s\\\"}\", req-\u003eerror_msg);\n  goto cleanup;\n}\n```\n\nExample response by validation:\n\n- Field password is required.\n- Field password min length is 6.\n- Field password max length is 16.\n\n### Get Headers\n\n```c\nconst char *origin = cHTTPX_Header(req, \"Origin\");\n```\n\ncHTTPX_Header - Get a request header by name.\n\n`Parameters`:\n\n- req – Pointer to the HTTP request.\n- name – Header name (case-insensitive).\n\n### Get Params\n\n\u003e The path must contain the /{uuid} construct.\n\n```c\nconst char *uuid = cHTTPX_Param(req, \"uuid\");\n```\n\ncHTTPX_Param - Get a route parameter value by its name.\n\n`Parameters`:\n\n- req – Pointer to the HTTP request.\n- name – Name of the route parameter (e.g., \"uuid\").\n\n### Get Query params\n\n```c\nconst char *sizeParam = cHTTPX_Query(req, \"size\");\n```\n\ncHTTPX_Query - Get a query parameter value by name.\n\n`Parameters`:\n\n- req – Pointer to the HTTP request.\n- name – Name of the query parameter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcorelink%2Flibchttpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcorelink%2Flibchttpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcorelink%2Flibchttpx/lists"}