{"id":22361716,"url":"https://github.com/foresthoffman/rwb","last_synced_at":"2025-10-03T21:11:50.310Z","repository":{"id":57577023,"uuid":"358425993","full_name":"foresthoffman/rwb","owner":"foresthoffman","description":"A Go package for intercepting HTTP(s) response values before sending them to the request client.","archived":false,"fork":false,"pushed_at":"2021-04-16T00:36:58.000Z","size":5,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T16:12:47.030Z","etag":null,"topics":["go","golang","http"],"latest_commit_sha":null,"homepage":"","language":"Go","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/foresthoffman.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}},"created_at":"2021-04-16T00:10:44.000Z","updated_at":"2023-04-06T18:22:35.000Z","dependencies_parsed_at":"2022-09-12T00:00:19.026Z","dependency_job_id":null,"html_url":"https://github.com/foresthoffman/rwb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Frwb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Frwb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Frwb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Frwb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foresthoffman","download_url":"https://codeload.github.com/foresthoffman/rwb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245674710,"owners_count":20654207,"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","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":["go","golang","http"],"created_at":"2024-12-04T16:32:31.333Z","updated_at":"2025-10-03T21:11:45.261Z","avatar_url":"https://github.com/foresthoffman.png","language":"Go","readme":"## RWB - Response Writer Buffer\n\nThe rwb package exposes a wrapper for the `http.ResponseWriter`, which allows for intercepting HTTP(s) response bodies and response headers. The `ResponseWriterBuffer` is lightweight and can assist in HTTP(s) server request handling, as well as server response middleware.\n\nHere's a guide to thinking in terms of *response* middleware and not just *request* middleware:\n\n[Intercepting RESTful Responses with Middleware](https://dev.to/foresthoffman/intercepting-restful-responses-with-middleware-4b64)\n\n### Installation\n\nRun `go get -u github.com/foresthoffman/rwb`\n\n### Importing\n\nImport this package by including `github.com/foresthoffman/rwb` in your import block.\n\ne.g.\n\n```go\npackage main\n\nimport(\n    ...\n    \"github.com/foresthoffman/rwb\"\n)\n```\n\n### Usage\n\nBasic usage:\n\n```go\npackage main\n\nimport (\n\t\"github.com/foresthoffman/rwb\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t// Hit http://localhost:9001/ in your browser, or cURL/wget it! It's up to you.\n\thttp.ListenAndServe(\":9001\", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// You could update the header directly.\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\t// New header exists.\n\t\tlog.Println(w.Header().Get(\"Content-Type\"))\n\n\t\t// Or you could write to the buffer, and flush it when you're done.\n\t\twriterBuf := rwb.New(w)\n\t\twriterBuf.Header().Set(\"potato\", \"russet\")\n\n\t\t// New header doesn't exist yet. It's in the buffer!\n\t\tlog.Println(w.Header().Get(\"potato\"))\n\n\t\t_, err := writerBuf.Flush()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\t// New header exists!\n\t\tlog.Println(w.Header().Get(\"potato\"))\n\t}))\n}\n```\n\n_That's all, enjoy!_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesthoffman%2Frwb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforesthoffman%2Frwb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesthoffman%2Frwb/lists"}