{"id":22056946,"url":"https://github.com/danteay/gin-extended","last_synced_at":"2026-04-19T19:34:21.562Z","repository":{"id":100303249,"uuid":"223247509","full_name":"danteay/gin-extended","owner":"danteay","description":"Implementation of usefull middlewares for gin framework","archived":false,"fork":false,"pushed_at":"2023-02-10T16:52:17.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-14T18:55:31.885Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danteay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-11-21T19:20:40.000Z","updated_at":"2023-02-10T16:52:18.000Z","dependencies_parsed_at":"2023-04-24T21:09:53.435Z","dependency_job_id":null,"html_url":"https://github.com/danteay/gin-extended","commit_stats":null,"previous_names":["danteay/gin-extended-commons"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/danteay/gin-extended","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danteay%2Fgin-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danteay%2Fgin-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danteay%2Fgin-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danteay%2Fgin-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danteay","download_url":"https://codeload.github.com/danteay/gin-extended/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danteay%2Fgin-extended/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32020697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":[],"created_at":"2024-11-30T16:15:31.098Z","updated_at":"2026-04-19T19:34:21.542Z","avatar_url":"https://github.com/danteay.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gin-Gonic Extended\n\nThis package stores usefully middlewares and libraries that could be implemented\non a Gin project\n\n## Installation\n\n```bash\ngo get -u -v github.com/danteay/gin-extended\n```\n\n## Content\n\n* [Middlewares](#middlewares)\n  * [Authentication](#authentication)\n  * [SwaggerValidator](#swagger-validator)\n  * [Zerolog](#zerolog)\n* [Libraries](#libraries)\n  * [Parse](#parse)\n    * [ParseYmlFile](#parse-yml-file)\n    * [ShouldParseYmlFile](#should-parse-yml-file)\n* [Extras](#extras)\n  * [Ginrest](#ginrest)\n\n\u003cspan id=\"middlewares\"\u003e\u003c/span\u003e\n\n## Middlewares\n\n\u003cspan id=\"authentication\"\u003e\u003c/span\u003e\n\n### Authentication\n\nThis middleware can authenticate request with by two different strategies; as a\n`bearer` token or with a `basic` authentication schema.\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    app.Use(mw.Authentication())\n\n    // ....\n\n    app.Run()\n}\n```\n\nYou can set custom configuration for this middleware:\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    authConf := \u0026mw.AuthorizationConfig{\n        Type:   \"bearer\",\n        APIKey: \"123456789\",\n    }\n\n    app.Use(mw.AuthenticationWithConfig())\n\n    // ....\n\n    app.Run()\n}\n```\n\nAlso you can config as basic authentication.\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    authConf := \u0026mw.AuthorizationConfig{\n        Type:            \"basic\",\n        AuthCredentials: []string{\"user\", \"password\"},\n    }\n\n    app.Use(mw.AuthenticationWithConfig())\n\n    // ....\n\n    app.Run()\n}\n```\n\nOr you can define a non static validation for the authentication\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    authConf := \u0026mw.AuthorizationConfig{\n        Type:      \"bearer\",\n        Validator: func (key string) bool {\n            var res bool\n\n            // validate key\n\n            return res\n        },\n    }\n\n    app.Use(mw.AuthenticationWithConfig())\n\n    // ....\n\n    app.Run()\n}\n```\n\n\u003cspan id=\"swagger-validator\"\u003e\u003c/span\u003e\n\n### SwaggerValidator\n\nThis middleware validate the api request and response schema with the OpenApi\nspecification. By default the middleware search for a file called `spec.yml`\nto load the API specification.\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    app.Use(mw.SwaggerValidator())\n\n    // ....\n\n    app.Run()\n}\n```\n\nAlso you can specify a route to load the specification.\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    app.Use(mw.SwaggerValidatorWithConfig(\u0026mw.SwaggerValidatorConfig{\n        Document: \"my_spec_file.yml\"\n    }))\n\n    // ....\n\n    app.Run()\n}\n```\n\n\u003cspan id=\"zerolog\"\u003e\u003c/span\u003e\n\n### Zerolog\n\nThis middleware provides a custom IO request interface for Gin with zerolog.\n\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    mw \"github.com/danteay/gin-extended-commons/middlewares\"\n)\n\nfunc main(){\n    app := gin.New()\n\n    app.Use(mw.Zerolog())\n\n    // ....\n\n    app.Run()\n}\n```\n\n\u003cspan id=\"libraries\"\u003e\u003c/span\u003e\n\n## Libraries\n\n\u003cspan id=\"parse\"\u003e\u003c/span\u003e\n\n### Parse\n\n\u003cspan id=\"parse-yml-file\"\u003e\u003c/span\u003e\n\n#### ParseYmlFile\n\nParse and marshall a yml file into a structure\n\n```yml\n# config.yml\n\nuser: \"user\"\npass: \"pass\"\n```\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/gin-gonic/gin\"\n    \"github.com/danteay/gin-extended-commons/libs\"\n)\n\ntype Data struct {\n    User string `json:\"user\"`\n    Pass string `json:\"pass\"`\n}\n\nfunc main() {\n    data := new(Data)\n\n    err := libs.ParseYmlFile(\"config.yml\")\n    if err != nil {\n        fmt.Println(err.Error())\n        return\n    }\n\n    fmt.Println(data)\n}\n\n// {user pass}\n```\n\n\u003cspan id=\"should-parse-yml-file\"\u003e\u003c/span\u003e\n\n#### ShouldParseYmlFile\n\nParse and marshall a yml file into a structure and panic if any error happens\n\n```yml\n# config.yml\n\nuser: \"user\"\npass: \"pass\"\n```\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/gin-gonic/gin\"\n    \"github.com/danteay/gin-extended-commons/libs\"\n)\n\ntype Data struct {\n    User string `json:\"user\"`\n    Pass string `json:\"pass\"`\n}\n\nfunc main() {\n    data := new(Data)\n\n    libs.ShouldParseYmlFile(\"config.yml\")\n\n    fmt.Println(data)\n}\n\n// {user pass}\n```\n\n\u003cspan id=\"extras\"\u003e\u003c/span\u003e\n\n## Extras\n\n### Ginrest\n\nThis is a dependency library that is used by the middlewares to provide an\nstandard payload response, you can review his specification from his\n[Github repo](https://github.com/danteay/ginrest), also you can use it on your own API routes to respond with this standard.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanteay%2Fgin-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanteay%2Fgin-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanteay%2Fgin-extended/lists"}