{"id":13543035,"url":"https://github.com/hossein1376/grape","last_synced_at":"2026-01-27T17:04:19.403Z","repository":{"id":206735101,"uuid":"717505618","full_name":"hossein1376/grape","owner":"hossein1376","description":"Modern, zero-dependency HTTP library for Go","archived":false,"fork":false,"pushed_at":"2025-12-21T17:53:30.000Z","size":164,"stargazers_count":148,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-21T18:53:44.279Z","etag":null,"topics":["go","http","router","validator"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/hossein1376/grape","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/hossein1376.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":null,"dco":null,"cla":null}},"created_at":"2023-11-11T17:06:05.000Z","updated_at":"2025-12-21T17:53:34.000Z","dependencies_parsed_at":"2023-11-15T15:30:09.062Z","dependency_job_id":"f53e01a6-34ce-426e-a850-6bfb2b16ba79","html_url":"https://github.com/hossein1376/grape","commit_stats":null,"previous_names":["hossein1376/grape"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hossein1376/grape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hossein1376%2Fgrape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hossein1376%2Fgrape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hossein1376%2Fgrape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hossein1376%2Fgrape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hossein1376","download_url":"https://codeload.github.com/hossein1376/grape/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hossein1376%2Fgrape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28816573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"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","http","router","validator"],"created_at":"2024-08-01T11:00:21.860Z","updated_at":"2026-01-27T17:04:19.398Z","avatar_url":"https://github.com/hossein1376.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Grape 🍇\n\nGrape is a modern, zero-dependency HTTP library for Go.\n\nIt's a thin wrapper around the standard library, providing helper functions to\nfacilitate faster and easier development, while adding only a single dependency \nto your projects.\n\n## Features\n\n- Zero-dependency, 100% compatible with the standard library\n- Structured logging with [log/slog](https://pkg.go.dev/log/slog)\n- Using new, improved [net/http](https://pkg.go.dev/net/http) router\n- Group routes and scope-specific middlewares\n- Read and write JSON via the [encoding/json](https://pkg.go.dev/encoding/json)\n- Boosting modular and customizable architecture\n- Featuring `validator` and `errs` packages for validation and graceful error\n  handling\n\n## Installation\n\nYou need Go version 1.25 or higher.\n\n```shell\ngo get -u github.com/hossein1376/grape@latest\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"log/slog\"\n\t\"net/http\"\n\t\"strconv\"\n\n\t\"github.com/hossein1376/grape\"\n\t\"github.com/hossein1376/grape/errs\"\n\t\"github.com/hossein1376/grape/slogger\"\n)\n\nfunc main() {\n\tslogger.NewDefault(slogger.WithLevel(slog.LevelDebug))\n\tr := grape.NewRouter()\n\tr.UseAll(\n\t\tgrape.RequestIDMiddleware,\n\t\tgrape.RecoverMiddleware,\n\t\tgrape.LoggerMiddleware,\n\t)\n\tr.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tgrape.Respond(r.Context(), w, http.StatusOK, \"Hello, World!\")\n\t})\n\tgroup := r.Group(\"\")\n\tgroup.Get(\"/{id}\", paramHandler)\n\n\t// Alternatively, you can call r.Serve(\":3000\", nil)\n\tsrv := \u0026http.Server{Addr: \":3000\", Handler: r}\n\tif err := srv.ListenAndServe(); err != nil {\n\t\tslog.Error(\"start server failure\", slogger.Err(\"error\", err))\n\t\treturn\n\t}\n}\n\nfunc paramHandler(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\tslogger.Debug(ctx, \"Param handler!\")\n\n\tid, err := grape.Param(r, \"id\", strconv.Atoi)\n\tif err != nil {\n\t\tgrape.ExtractFromErr(\n\t\t\tctx,\n\t\t\tw,\n\t\t\terrs.BadRequest(errs.WithErr(err), errs.WithMsg(\"invalid id\")),\n\t\t)\n\t\treturn\n\t}\n\n\tgrape.Respond(ctx, w, http.StatusOK, grape.Map{\"id\": id})\n}\n```\n\nMore code samples can be found inside the [examples](/_examples) directory.\n\n## Composability\n\nGrape consists of several components independent of each other. Giving developers\n**opt-in** choice of features.\n\n### `grape.Router`\n\nEnable routing via HTTP named methods, with route grouping and scope-specific\nmiddlewares. Create a new instance by calling `grape.NewRouter()`.  \nAll routes are registered on server's startup and the rest is handled by the\nstandard library, causing zero runtime overhead.\n\n### `slogger` package\n\nActing as an abstraction over `log/slog` package, it creates a new logger with\nthe provided functional options, and optionally set it as the default logger.  \nIt also exposes wrapper functions around `slog.LogAttrs` for efficient and less\nerror-prone logging.\n\n### `errs` package\n\nUsed for effortlessly conveying error details, messages and relevant status code\nbetween different functions and application layers . Paired with `ExtractFromErr`,\nJSON responses can be automatically derived and written.\n\n### `validator` package\n\nPresenting wide range of functions for data validation. Start a new instance with\n`validator.New()` and then use `Check` on each part of your data with as many\n`Case` it's necessary.\n\n## Why?\n\nGo standard library is awesome. It's fast, easy to use, and has a great API.  \nWith the addition of `log/slog` in go 1.21 and improved HTTP router in go 1.22,\nthere are not many reasons to look any further.  \nInstead of breaking compatibility with the `net/http`, Grape aims to add commonly\nused functions within the arm's reach of developers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhossein1376%2Fgrape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhossein1376%2Fgrape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhossein1376%2Fgrape/lists"}