{"id":30848401,"url":"https://github.com/itpey/echocbor","last_synced_at":"2026-05-10T16:02:38.204Z","repository":{"id":310118839,"uuid":"1038734813","full_name":"itpey/echocbor","owner":"itpey","description":"CBOR middleware for the Echo web framework.","archived":false,"fork":false,"pushed_at":"2025-08-15T20:27:47.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-15T22:36:39.144Z","etag":null,"topics":["cbor","cbor-library","echo","echo-framework","encoder-decoder","go","golang","golang-package","json","marshal","rest-api","restful-api","unmarshal"],"latest_commit_sha":null,"homepage":"https://github.com/itpey/echocbor","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itpey.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,"zenodo":null}},"created_at":"2025-08-15T18:17:23.000Z","updated_at":"2025-08-15T20:27:50.000Z","dependencies_parsed_at":"2025-08-15T22:36:40.515Z","dependency_job_id":"6bb38346-3794-47b8-96e5-2f8efb4d16c3","html_url":"https://github.com/itpey/echocbor","commit_stats":null,"previous_names":["itpey/echocbor"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/itpey/echocbor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Fechocbor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Fechocbor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Fechocbor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Fechocbor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itpey","download_url":"https://codeload.github.com/itpey/echocbor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Fechocbor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273990399,"owners_count":25203334,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cbor","cbor-library","echo","echo-framework","encoder-decoder","go","golang","golang-package","json","marshal","rest-api","restful-api","unmarshal"],"created_at":"2025-09-07T03:11:05.909Z","updated_at":"2026-05-10T16:02:38.072Z","avatar_url":"https://github.com/itpey.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Echo CBOR Middleware\n\n[![Go Version][GoVer-Image]][GoDoc-Url] [![License][License-Image]][License-Url] [![GoDoc][GoDoc-Image]][GoDoc-Url] [![Go Report Card][ReportCard-Image]][ReportCard-Url]\n\n[GoVer-Image]: https://img.shields.io/badge/Go-1.24%2B-blue\n[GoDoc-Url]: https://pkg.go.dev/github.com/itpey/echocbor\n[GoDoc-Image]: https://pkg.go.dev/badge/github.com/itpey/echocbor.svg\n[ReportCard-Url]: https://goreportcard.com/report/github.com/itpey/echocbor\n[ReportCard-Image]: https://goreportcard.com/badge/github.com/itpey/echocbor?style=flat\n[License-Url]: https://github.com/itpey/echocbor/blob/main/LICENSE\n[License-Image]: https://img.shields.io/github/license/itpey/echocbor\n\nEcho CBOR is a middleware for the Echo web framework that enables encoding and decoding of CBOR (Concise Binary Object Representation) data in HTTP requests and responses using the [fxamacker/cbor](https://github.com/fxamacker/cbor) library.\n\n## Features\n\n- Adds a `Cbor` method to the Echo context for sending CBOR-encoded responses.\n- Provides a custom `Binder` to decode CBOR request bodies.\n- Middleware to wrap the Echo context for CBOR support.\n- Lightweight and easy to integrate with existing Echo applications.\n\n## Installation\n\nTo install the package, use the following command:\n\n```bash\ngo get -u github.com/itpey/echocbor\n```\n\n## Usage\n\n### Setting Up the Middleware\n\nTo use the CBOR middleware, wrap your Echo handlers with the `ContextWrapper` middleware and set the custom `Binder`. Here's an example:\n\n```go\npackage main\n\nimport (\n    \"net/http\"\n\n    \"github.com/labstack/echo/v4\"\n    \"github.com/itpey/echocbor\"\n)\n\nfunc main() {\n    e := echo.New()\n\n    // Set the custom CBOR binder\n    e.Binder = \u0026echocbor.Binder{}\n\n    // Use the CBOR context wrapper middleware\n    e.Use(echocbor.ContextWrapper)\n\n    // Example route\n    e.POST(\"/example\", func(c echo.Context) error {\n        // Define a struct to bind the request body\n        type Payload struct {\n            Name string `json:\"name\" cbor:\"name\"`\n            Age  int    `json:\"age\" cbor:\"age\"`\n        }\n\n        // Bind the CBOR request body\n        var payload Payload\n        if err := c.Bind(\u0026payload); err != nil {\n            return err\n        }\n\n        // Send a CBOR response\n        return c.(echocbor.Context).Cbor(http.StatusOK, map[string]interface{}{\n            \"message\": \"Received\",\n            \"data\":    payload,\n        })\n    })\n\n    e.Logger.Fatal(e.Start(\":8080\"))\n}\n```\n\n### Sending CBOR Responses\n\nThe `Cbor` method allows you to send a CBOR-encoded response with a specified HTTP status code. For example:\n\n```go\ne.GET(\"/data\", func(c echo.Context) error {\n    data := map[string]interface{}{\n        \"id\":   1,\n        \"name\": \"John Doe\",\n    }\n    return c.(echocbor.Context).Cbor(http.StatusOK, data)\n})\n```\n\n## Feedback and Contributions\n\nIf you encounter any issues or have suggestions for improvement, please [open an issue](https://github.com/itpey/echocbor/issues) on GitHub.\n\nWe welcome contributions! Fork the repository, make your changes, and submit a pull request.\n\n## Support\n\nIf you enjoy using Echo CBOR, please consider giving it a star! Your support helps others discover the project and encourages further development.\n\n## License\n\nEcho CBOR is open-source software released under the Apache License, Version 2.0. You can find a copy of the license in the [LICENSE](https://github.com/itpey/echocbor/blob/main/LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpey%2Fechocbor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitpey%2Fechocbor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpey%2Fechocbor/lists"}