{"id":26925133,"url":"https://github.com/rmhubbert/rmhttp","last_synced_at":"2026-04-19T23:06:01.484Z","repository":{"id":260846162,"uuid":"841825920","full_name":"rmhubbert/rmhttp","owner":"rmhubbert","description":"rmhttp is a lightweight wrapper around the Go standard library HTTP server \u0026 router with a fluent interface for adding routes, groups, timeouts, headers \u0026 middleware.","archived":false,"fork":false,"pushed_at":"2026-03-21T21:45:54.000Z","size":292,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-22T09:57:54.260Z","etag":null,"topics":["go","golang","golang-library","http-server","http-server-library"],"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/rmhubbert.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2024-08-13T05:53:15.000Z","updated_at":"2026-03-21T21:45:15.000Z","dependencies_parsed_at":"2024-11-03T02:18:28.441Z","dependency_job_id":"f632a208-12cc-4e59-88e6-581dcf29c158","html_url":"https://github.com/rmhubbert/rmhttp","commit_stats":null,"previous_names":["rmhubbert/rmhttp"],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/rmhubbert/rmhttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Frmhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Frmhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Frmhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Frmhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmhubbert","download_url":"https://codeload.github.com/rmhubbert/rmhttp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Frmhttp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"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":["go","golang","golang-library","http-server","http-server-library"],"created_at":"2025-04-02T02:30:21.031Z","updated_at":"2026-04-01T22:19:36.466Z","avatar_url":"https://github.com/rmhubbert.png","language":"Go","readme":"# rmhttp\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/rmhubbert/rmhttp.svg)](https://pkg.go.dev/github.com/rmhubbert/rmhttp) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/rmhubbert/rmhttp?color=%23007D9C)\n![GitHub Release Date](https://img.shields.io/github/release-date/rmhubbert/rmhttp?color=%23007D9C)\n![GitHub commits since latest release](https://img.shields.io/github/commits-since/rmhubbert/rmhttp/latest?color=%23007D9C) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?color=%23007D9C)](CONTRIBUTING.md)\n\n**rmhttp** provides a lightweight wrapper around the Go standard library HTTP server and router provided by [net/http](https://pkg.go.dev/net/http) that allows for the easy addition of timeouts, groups, headers, and middleware (at the route, group and server level).\n\nThis package aims to make it easier to configure your routes and middleware, but then hand off as much as possible to the standard library once the server is running. Standard net/http handlers and middleware functions are used throughout.\n\n## Installation\n\nRun the following command from your project root directory to install **rmhttp** into your project.\n\n```bash\ngo get github.com/rmhubbert/rmhttp/v5\n```\n\n## Quickstart\n\nThe following code will get you up and running quickly with a basic GET endpoint.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n)\n\nfunc myHandler := func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusOK)\n    w.Write([]byte(\"Hello World\"))\n}\n\nfunc main() {\n    // New() creates and intialises the app. You can optionally pass\n    // in a configuration object.\n    rmh := rmhttp.New()\n\n    // Handle(), HandleFunc(), Post(), Put(), Patch(), Delete() and\n    // Options() methods are also available.\n    rmh.Get(\"/hello\", myHandler)\n\n    // ListenAndServe() starts the server.\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n## Configuration\n\nConfiguration options can be set via environment variables or by passing in a Config object to the New() method, See [https://github.com/rmhubbert/rmhttp/blob/main/config.go](config.go) for details.\n\n## Usage\n\n**rmhttp** offers a fluent interface for building out your server functionality, allowing you to easily customise your server, groups, and routes. Here are some simple examples of the core functionality to get you started.\n\n### Error Handling\n\nYou can register your own handlers for 404 and 405 errors. These errors are normally triggered internally by http.ServeMux, and are normally not configurable.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n)\n\nfunc my404Handler := func(w http.ResponseWriter, r *http.Request) {\n    http.Error(w, \"My 404 Message\", http.StatusNotFound)\n}\n\nfunc my405Handler := func(w http.ResponseWriter, r *http.Request) {\n    http.Error(w, \"My 405 Message\", http.StatusMethodNotAllowed)\n}\n\nfunc main() {\n    rmh := rmhttp.New()\n    // This handler will replace the default 404 HTTP status code handler.\n    rmh.StatusNotFoundHandler(my404Handler)\n\n\t// This handler will replace the default 405 HTTP status code handler.\n    rmh.StatusMethodNotAllowedHandler(my405Handler)\n\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n### Groups\n\nRoutes can be easily grouped by registering them with a Group object. This allows all of the routes registered this way to inherit the group URL pattern plus any configured headers and middleware.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n)\n\nfunc myHandler := func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusOK)\n    w.Write([]byte(\"Hello World\"))\n}\n\nfunc main() {\n    rmh := rmhttp.New()\n    // The following creates a Group and then registers a Get route with that Group.\n    // The route will be accessible at /api/hello.\n    rmh.Group(\"/api\").Get(\"/hello\", myHandler)\n\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n### Headers\n\nHeaders can be easily added at the global, group, and route level by calling WithHeader() on the desired target.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n)\n\nfunc myHandler := func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusOK)\n    w.Write([]byte(\"Hello World\"))\n}\n\nfunc main() {\n    rmh := rmhttp.New().WithHeader(\"X-Hello\", \"World\")\n    rmh.Get(\"/hello\", myHandler).WithHeader(\"X-My\", \"Header\")\n\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n### Timeouts\n\nTimeouts can be easily added at the global, group, and route level by calling WithTimeout() on the desired target. The length of timeout is set in seconds.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n)\n\nfunc myHandler := func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusOK)\n    w.Write([]byte(\"Hello World\"))\n}\n\nfunc main() {\n    rmh := rmhttp.New().WithTimeout(5, \"Global timeout message\")\n    rmh.Get(\"/hello\", myHandler).WithTimeout(3, \"Route timeout message\")\n\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n### Middleware\n\nMiddleware can be easily added at the global, group, and route level by calling WithMiddleware() or Use() on the desired target.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rmhubbert/rmhttp/v5\"\n\t\"github.com/rmhubbert/rmhttp/v5/pkg/middleware/recoverer\"\n)\n\nfunc myHandler := func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusOK)\n    w.Write([]byte(\"Hello World\"))\n}\n\nfunc main() {\n    rmh := rmhttp.New().WithMiddleware(recoverer.Middleware())\n    rmh.Get(\"/hello\", myHandler)\n\n    log.Fatal(rmh.ListenAndServe())\n}\n```\n\n## License\n\n**rmhttp** is made available for use via the [MIT license](LICENSE).\n\n## Contributing\n\nContributions are always welcome via [Pull Request](https://github.com/rmhubbert/rmhttp/pulls). Please make sure to add tests and make sure they are passing before submitting. It's also a good idea to lint your code with golintci-lint, using the config in this directory.\n\nContributors are expected to abide by the guidelines outlined in the [Contributor Covenant Code of Conduct](CONTRIBUTING.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmhubbert%2Frmhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmhubbert%2Frmhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmhubbert%2Frmhttp/lists"}