{"id":20950494,"url":"https://github.com/zigzap/mini-proxy","last_synced_at":"2025-10-04T15:55:40.735Z","repository":{"id":170048879,"uuid":"646140231","full_name":"zigzap/mini-proxy","owner":"zigzap","description":"Just an example illustrating how to use std.http from within zap (dangerous!)","archived":false,"fork":false,"pushed_at":"2023-05-27T13:29:35.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T23:35:56.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zigzap.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}},"created_at":"2023-05-27T12:17:23.000Z","updated_at":"2023-10-06T10:19:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"674bdd13-6a3e-4e67-b1d3-6ffebbbbe1f2","html_url":"https://github.com/zigzap/mini-proxy","commit_stats":null,"previous_names":["zigzap/mini-proxy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zigzap/mini-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigzap%2Fmini-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigzap%2Fmini-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigzap%2Fmini-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigzap%2Fmini-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zigzap","download_url":"https://codeload.github.com/zigzap/mini-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigzap%2Fmini-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278335450,"owners_count":25970129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-19T00:48:53.198Z","updated_at":"2025-10-04T15:55:40.705Z","avatar_url":"https://github.com/zigzap.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mini Proxy Example\n\nThis is just an example to demonstrate that you can make HTTP requests inside\nyour request handlers, although I strongly advise against it. It blocks your\nvaluable worker thread for a time you have no control over.\n\n## Running the demo\n\n1. Have some other server running on port 8000\n\n```console\n$ python -m http.server\n```\n\n2. Start this server\n\n```console\n$ zig build run\n```\n3. Browse the directory indirectly\n\n```console\n$ curl http://localhost:3000/\n$ curl http://localhost:3000/src/main.zig\n\n# etc\n```\n\n## Why is this dangerouse\n\nThe reasons I advise against depending on HTTP requests directly from within your\nrequest handler, are briefly:\n\n- you make a 3rd party server's latency your own.\n- if for some (malicious) reason the remote server sends its response really,\n  really slowly, you might find yourself in a slow loris situation, eventually\n  starving ALL your worker threads, rendering your server \"dead\" or\n  unresponsive.\n\n## What would be a better approach?\n\n- use the worker threads (request handlers) to dispatch the work to some other\n  thread (pool) that executes potentially long-running tasks, and immediately\n  return a handle or an ID that identifies the request.\n- have your clients poll your server to query whether the potentially long-running\n  task with the provided handle has yielded a result yet.\n- if the long-running task has completed, return the result upon the next poll.\n\nEssentially, make potentially long-running tasks execute asynchronously and\nyou'll \"never\" risk having your entire server blocked by slow external\nresources.\n\n### If you're brave\n\nThere is SOME support for pausing and resuming request handlers in facil.io. So,\nbasically, you can `http_pause()` your request, have some other thread\n`http_resume()` it, check if a response can be sent, and decide whether to\n`http_pause()` it again or use `http_send_...()` / `http_finish()` on it.\n\nThere's no zap wrapping of this functionality yet, but if you're fine with using\nfacil.io's data structures directly, you can already use it via\n`zap.http_pause()`, etc.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigzap%2Fmini-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzigzap%2Fmini-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigzap%2Fmini-proxy/lists"}