{"id":13794044,"url":"https://github.com/gin-contrib/static","last_synced_at":"2025-06-13T18:39:31.690Z","repository":{"id":15266205,"uuid":"76311792","full_name":"gin-contrib/static","owner":"gin-contrib","description":"Static middleware","archived":false,"fork":false,"pushed_at":"2024-05-05T01:06:37.000Z","size":955,"stargazers_count":267,"open_issues_count":5,"forks_count":41,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-05T02:22:30.802Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gin-contrib.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":"2016-12-13T01:40:49.000Z","updated_at":"2024-05-05T02:22:34.088Z","dependencies_parsed_at":"2024-01-13T10:13:47.604Z","dependency_job_id":"09af825c-cd03-41e6-8187-4d3d1914633c","html_url":"https://github.com/gin-contrib/static","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fstatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fstatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fstatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fstatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gin-contrib","download_url":"https://codeload.github.com/gin-contrib/static/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816746,"owners_count":21968876,"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":[],"created_at":"2024-08-03T23:00:35.046Z","updated_at":"2025-05-12T20:31:22.428Z","avatar_url":"https://github.com/gin-contrib.png","language":"Go","readme":"# static middleware\n\n[![Run Tests](https://github.com/gin-contrib/static/actions/workflows/go.yml/badge.svg)](https://github.com/gin-contrib/static/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/gin-contrib/static/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/static)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/static)](https://goreportcard.com/report/github.com/gin-contrib/static)\n[![GoDoc](https://godoc.org/github.com/gin-contrib/static?status.svg)](https://godoc.org/github.com/gin-contrib/static)\n\nStatic middleware\n\n## Usage\n\n### Start using it\n\nDownload and install it:\n\n```sh\ngo get github.com/gin-contrib/static\n```\n\nImport it in your code:\n\n```go\nimport \"github.com/gin-contrib/static\"\n```\n\n### Canonical example\n\nSee the [example](_example)\n\n#### Serve local file\n\n```go\npackage main\n\nimport (\n  \"embed\"\n  \"fmt\"\n  \"net/http\"\n\n  \"github.com/gin-contrib/static\"\n  \"github.com/gin-gonic/gin\"\n)\n\n//go:embed data\nvar server embed.FS\n\nfunc main() {\n  r := gin.Default()\n  fs, err := static.EmbedFolder(server, \"data/server\")\n  if err != nil {\n    panic(err)\n  }\n  r.Use(static.Serve(\"/\", fs))\n  r.GET(\"/ping\", func(c *gin.Context) {\n    c.String(200, \"test\")\n  })\n  r.NoRoute(func(c *gin.Context) {\n    fmt.Printf(\"%s doesn't exists, redirect on /\\n\", c.Request.URL.Path)\n    c.Redirect(http.StatusMovedPermanently, \"/\")\n  })\n  // Listen and Server in 0.0.0.0:8080\n  r.Run(\":8080\")\n}\n\n```\n","funding_links":[],"categories":["Middlewares","Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fstatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgin-contrib%2Fstatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fstatic/lists"}