{"id":28390527,"url":"https://github.com/ainvaltin/httpsrv","last_synced_at":"2025-06-28T03:30:56.044Z","repository":{"id":65149580,"uuid":"582984694","full_name":"ainvaltin/httpsrv","owner":"ainvaltin","description":"Package httpsrv implements minimalist \"framework\" to manage http server lifetime.","archived":false,"fork":false,"pushed_at":"2023-11-11T10:57:58.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T15:20:18.609Z","etag":null,"topics":["http","server"],"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/ainvaltin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-12-28T12:25:48.000Z","updated_at":"2023-01-31T22:46:56.000Z","dependencies_parsed_at":"2023-02-16T01:30:43.188Z","dependency_job_id":"71bb912e-1b7d-4f1f-af78-f5c19260d273","html_url":"https://github.com/ainvaltin/httpsrv","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ainvaltin/httpsrv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ainvaltin%2Fhttpsrv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ainvaltin%2Fhttpsrv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ainvaltin%2Fhttpsrv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ainvaltin%2Fhttpsrv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ainvaltin","download_url":"https://codeload.github.com/ainvaltin/httpsrv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ainvaltin%2Fhttpsrv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262371083,"owners_count":23300556,"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":["http","server"],"created_at":"2025-05-31T05:13:08.807Z","updated_at":"2025-06-28T03:30:56.025Z","avatar_url":"https://github.com/ainvaltin.png","language":"Go","readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/ainvaltin/httpsrv.svg)](https://pkg.go.dev/github.com/ainvaltin/httpsrv)\n\n# httpsrv\n\nPackage `httpsrv` implements minimalist \"framework\" to manage http server lifetime.\n\nSetting up server and managing it's lifetime is repetitive and it is easy to\nintroduce subtle bugs. This library aims to solve these problems for http server\nwhile being router agnostic and \"errgroup pattern\" friendly.\n\nSimple example of using this package:\n\n```go\nfunc main() {\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/\", func(w http.ResponseWriter, req *http.Request) {\n\t\tfmt.Fprint(w, \"Hello, World!\")\n\t})\n\n\terr := httpsrv.Run(ctx, \u0026http.Server{Addr: \"127.0.0.1:8080\", Handler: mux})\n\tfmt.Println(\"server exited:\", err)\n}\n```\n\n## errgroup pattern\n\nSimply put \"errgroup pattern\" is a organization of the service code so that all\nsubprocesses of the service are launched as members of the same\n[errgroup](https://pkg.go.dev/golang.org/x/sync/errgroup) and their lifetime is\ncontrolled by the context of the group. This means that when one of the group members\nexits with error the group's context gets cancelled and all other group members\nget signal to (gracefully) exit too. Group reports the first error as the reason\nservice stopped.\n\nRules for a func starting a subprocess are:\n - every group member lifetime is controlled by group's context - when it gets cancelled\n the subprocess should exit (gracefully) ASAP;\n - subprocess always returns non-nil error (most of the time it would be the `ctx.Err()`\n ie the subprocess exits because the context controlling it's lifetime has been cancelled).\n\nSee the [example project](./examples/errgroup/) for more.\n\n## Possible improvements\n\n- support user defined panic handlers so that if none of the handlers mark panic as \"handled\"\nthen service will be shut down (IOW configurable `ShutdownOnPanic`);\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fainvaltin%2Fhttpsrv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fainvaltin%2Fhttpsrv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fainvaltin%2Fhttpsrv/lists"}