{"id":25478653,"url":"https://github.com/bastianrob/httpmiddleware","last_synced_at":"2025-11-06T12:30:29.110Z","repository":{"id":98852872,"uuid":"190689424","full_name":"bastianrob/httpmiddleware","owner":"bastianrob","description":null,"archived":false,"fork":false,"pushed_at":"2019-06-07T04:48:49.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2023-03-02T22:56:43.671Z","etag":null,"topics":["go","golang","http-middleware"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bastianrob.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-06-07T04:48:01.000Z","updated_at":"2024-06-19T07:43:59.659Z","dependencies_parsed_at":"2023-03-23T13:18:09.910Z","dependency_job_id":null,"html_url":"https://github.com/bastianrob/httpmiddleware","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastianrob%2Fhttpmiddleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastianrob%2Fhttpmiddleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastianrob%2Fhttpmiddleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastianrob%2Fhttpmiddleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bastianrob","download_url":"https://codeload.github.com/bastianrob/httpmiddleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239493707,"owners_count":19647995,"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-middleware"],"created_at":"2025-02-18T14:53:25.963Z","updated_at":"2025-11-06T12:30:29.046Z","avatar_url":"https://github.com/bastianrob.png","language":"Go","readme":"# HTTP Middleware\n\nA middleware to chain HTTP request handler\n\n## Example\n\n```go\nstep1 := func(number int) HTTPMiddleware {\n\treturn func(h http.HandlerFunc) http.HandlerFunc {\n\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Header().Set(\"number\", strconv.Itoa(number))\n\t\t\th.ServeHTTP(w, r)\n\t\t}\n\t}\n}\n\nstep2 := func(word string) HTTPMiddleware {\n\treturn func(h http.HandlerFunc) http.HandlerFunc {\n\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Header().Set(\"word\", word)\n\t\t\th.ServeHTTP(w, r)\n\t\t}\n\t}\n}\n\napi := func(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(http.StatusOK)\n}\n\npipeline := httpmiddleware.NewPipeline().\n\t\tDo(step1(100)).\n\t\tDo(step2(\"I am a word\")).\n\t\tFor(api)\n\t\t\nrouter := http.NewServeMux()\nrouter.Handle(\"/\", pipeline)\n\nreq := httptest.NewRequest(\"GET\", \"/\", nil)\nrec := httptest.NewRecorder()\n\nrouter.ServeHTTP(rec, req)\nlog.Println(rec.Code, rec.Header().Get(\"number\"), rec.Header().Get(\"word\"))\n//200 100 I am a word\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastianrob%2Fhttpmiddleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbastianrob%2Fhttpmiddleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastianrob%2Fhttpmiddleware/lists"}