MCPcopy Index your code
hub / github.com/gin-contrib/static

github.com/gin-contrib/static @v1.1.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.6 ↗ · + Follow
30 symbols 94 edges 11 files 10 documented · 33% 20 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

static middleware

Run Tests Trivy Security Scan codecov Go Report Card GoDoc

Static middleware

Usage

Start using it

Download and install it:

go get github.com/gin-contrib/static

Import it in your code:

import "github.com/gin-contrib/static"

Canonical example

See the example

Serve local file

package main

import (
  "embed"
  "fmt"
  "net/http"

  "github.com/gin-contrib/static"
  "github.com/gin-gonic/gin"
)

//go:embed data
var server embed.FS

func main() {
  r := gin.Default()
  fs, err := static.EmbedFolder(server, "data/server")
  if err != nil {
    panic(err)
  }
  r.Use(static.Serve("/", fs))
  r.GET("/ping", func(c *gin.Context) {
    c.String(200, "test")
  })
  r.NoRoute(func(c *gin.Context) {
    fmt.Printf("%s doesn't exists, redirect on /\n", c.Request.URL.Path)
    c.Redirect(http.StatusMovedPermanently, "/")
  })
  // Listen and Server in 0.0.0.0:8080
  r.Run(":8080")
}

Extension points exported contracts — how you extend this code

ServeFileSystem (Interface)
(no doc) [3 implementers]
serve.go

Core symbols most depended-on inside this repo

Serve
called by 7
serve.go
LocalFile
called by 4
local_file.go
Exists
called by 4
serve.go
ServeRoot
called by 3
serve.go
EmbedFolder
called by 3
embed_folder.go
Exists
called by 0
local_file.go
Exists
called by 0
embed_folder.go
main
called by 0
_example/simple/example.go

Shape

Function 20
Method 5
Struct 4
Interface 1

Languages

Go100%

Modules by API surface

_example/bindata/bindata.go7 symbols
_example/bindata/example.go5 symbols
serve.go4 symbols
serve_test.go3 symbols
local_file.go3 symbols
embed_folder.go3 symbols
local_file_test.go1 symbols
embed_folder_test.go1 symbols
benchmark_test.go1 symbols
_example/simple/example.go1 symbols
_example/embed/example.go1 symbols

For agents

$ claude mcp add static \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page