{"id":26919260,"url":"https://github.com/studiolambda/akumu","last_synced_at":"2025-04-01T21:32:47.162Z","repository":{"id":211504865,"uuid":"729260312","full_name":"StudioLambda/Akumu","owner":"StudioLambda","description":"A zero-dependencies Go web framework with support for Problem Details (RFC 9457). Integrates seamlessly with the Go standard library","archived":false,"fork":false,"pushed_at":"2025-02-24T18:13:17.000Z","size":9567,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-24T19:25:02.087Z","etag":null,"topics":["framework","go","golang","web"],"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/StudioLambda.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-08T18:40:29.000Z","updated_at":"2025-02-24T18:13:02.000Z","dependencies_parsed_at":"2024-08-06T22:16:50.247Z","dependency_job_id":"de7412d6-767e-4bbb-89c1-1810aa3a0efb","html_url":"https://github.com/StudioLambda/Akumu","commit_stats":null,"previous_names":["studiolambda/akumu"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudioLambda%2FAkumu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudioLambda%2FAkumu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudioLambda%2FAkumu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudioLambda%2FAkumu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StudioLambda","download_url":"https://codeload.github.com/StudioLambda/Akumu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246713004,"owners_count":20821829,"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":["framework","go","golang","web"],"created_at":"2025-04-01T21:31:03.559Z","updated_at":"2025-04-01T21:32:47.154Z","avatar_url":"https://github.com/StudioLambda.png","language":"Go","readme":"# Akumu\n\nAkumu is a zero-dependencies framework built on top of Go's net/http package.\n\nIt introduces powerful features like routing, middleware, and utilities to\nstreamline web development. Akumu also includes native support for Problem Details\nfor HTTP APIs (RFC 9457), making it easy to create standards-compliant APIs.\n\n## Key Features\n\n- Custom Handler Interface: Simplifies HTTP handler creation using `func(*http.Request) error`,\n  allowing handlers to return arbitrary errors.\n- Error Handling with Responder Interface: Any returned error is checked for Responder\n  implementation, providing flexibility in crafting responses.\n- Automatic error stack when a failure is provided. Errors and problems automatically craft\n  an error stack in an specific field.\n- Built-In Response Builder: Quickly build and customize responses while adhering to best\n  practices like setting appropriate HTTP headers.\n- Middleware Support: Seamlessly integrate custom or provided middlewares for cleaner,\n  modularized code.\n- Router with Grouping: Organize routes and apply middlewares at different levels using\n  the router's grouping capabilities.\n\n## Benefits\n\n- Ease of Use: Streamlined handler signature and built-in utilities minimize boilerplate.\n- Custom Error Handling: The Responder interface enables consistent and maintainable error responses.\n- Flexibility: Compatible with Go's native HTTP server and works seamlessly with other routers.\n- Standards Compliance: Built-in support for Problem Details (RFC 9457) simplifies API error reporting.\n\n## Installation\n\n```sh\ngo get github.com/studiolambda/akumu\n```\n\n## Documentation\n\nAkumu's source code is very well documented and godoc makes it a joy to look and understand\nthat documentation. Please refer to the official [API documentation](https://pkg.go.dev/github.com/studiolambda/akumu) to learn more.\n\n## Example\n\nBelow is an example demonstrating Akumu's core features: routing, middleware, and error handling.\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"log/slog\"\n\t\"net/http\"\n\n\t\"github.com/studiolambda/akumu\"\n\t\"github.com/studiolambda/akumu/middleware\"\n)\n\n// Define specific Problem errors that are easy to use\n// and maintain. The framework handles very well.\n\nvar ErrInvalidCookieValue = akumu.Problem{\n\tTitle:  \"invalid cookie value\",\n\tDetail: \"the cookie existed but contained an invalid value\",\n\tStatus: http.StatusBadRequest,\n}\n\nfunc helloWorld(request *http.Request) error {\n\n\t// Responses can be any error, but using the built-in\n\t// response builder will quickly get the job done\n\t// in most situations.\n\n\tcookie, err := request.Cookie(\"foo\")\n\n\tif err != nil {\n\n\t\t// Wraping errors with Failed creates a new response\n\t\t// builder, allowing appending or tweaking how a response\n\t\t// behaves.\n\n\t\treturn akumu.\n\t\t\tFailed(err).\n\t\t\tStatus(http.StatusConflict)\n\t}\n\n\tif cookie.Value != \"hello-word\" {\n\n\t\t// Returning Problem errors allows for quick and easy\n\t\t// errors that are not only mantainable but also use the RFC:\n\t\t// https://datatracker.ietf.org/doc/html/rfc9457\n\n\t\treturn akumu.Failed(ErrInvalidCookieValue)\n\t}\n\n\t// The Builder contain many useful methods for quickly building\n\t// http responses, such as appending headers, cookies or transforming\n\t// body data into specific content types (HTML, JSON, etc).\n\t//\n\t// Not only does it help transforming but also use the apropiate\n\t// headers for the responses.\n\t//\n\t// For example, you can use HTTP Streaming with the SSE or Stream\n\t// methods and the HTTP headers will be set for you (although you can\n\t// always modify them after calling the method).\n\n\treturn akumu.\n\t\tResponse(http.StatusOK).\n\t\tText(\"Hello, World\")\n}\n\nfunc notify(handler http.Handler) http.Handler {\n\n\t// Implement any middleware, or use existing middlewares\n\t// from the github.com/studiolambda/akumu/middlewares pkg.\n\n\treturn http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {\n\t\tslog.Info(\"new request has been made\", \"url\", request.URL)\n\n\t\thandler.ServeHTTP(writer, request)\n\t})\n}\n\nfunc main() {\n\n\t// Create a new HTTP router or use any existing\n\t// routers such as http.ServeMux or Chi router.\n\n\trouter := akumu.NewRouter()\n\n\t// Calling Use appends a new middleware to the current\n\t// router stack. Any route after this one, will\n\t// pass through this middleware.\n\n\trouter.Use(middleware.Recover())\n\n\t// Registering a route is a simple operation that just requires\n\t// the pattern and the handler to register.\n\n\trouter.Get(\"/\", helloWorld)\n\n\t// Route gruping can be done quite easy by just calling the Group\n\t// method and providing a prefix to use (\"\" is also valid). The provided\n\t// sub-router inherits the middleware and prefix from the previous router.\n\n\trouter.Group(\"/prefix\", func(router *akumu.Router) {\n\n\t\t// This middleware will only be used by this sub-router, the previous\n\t\t// router will not get affected.\n\t\t//\n\t\t// In particular, the Logger middleware allows using an slog.Logger instance\n\t\t// to quickly log any error on the server error range [500, 600).\n\n\t\trouter.Use(middleware.LoggerDefault())\n\n\t\t// The With method can be used to create in-line routers that are perfect\n\t\t// for using when middlewares need to be applied directly to the handlers.\n\t\t//\n\t\t// In this case, this route will be /prefix/foo and will use the 3 middlewares\n\t\t// in the chain (recover, logger and notify) in this order:\n\t\t// recover -\u003e logger -\u003e notify -\u003e helloWorld.\n\n\t\trouter.\n\t\t\tWith(notify).\n\t\t\tPost(\"/foo\", helloWorld)\n\t})\n\n\tif err := http.ListenAndServe(\":8080\", router); !errors.Is(err, http.ErrServerClosed) {\n\t\tslog.Error(\"failed serving http server\", \"err\", err)\n\t}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiolambda%2Fakumu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudiolambda%2Fakumu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiolambda%2Fakumu/lists"}