Static middleware
Go to file
Bo-Yi Wu cf788af04f add readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-13 10:10:13 +08:00
example fix import path. 2016-12-13 10:06:25 +08:00
.gitignore initital. 2016-12-13 10:03:34 +08:00
.travis.yml initital. 2016-12-13 10:03:34 +08:00
LICENSE Initial commit 2016-12-13 09:40:49 +08:00
README.md add readme. 2016-12-13 10:10:13 +08:00
static.go fix import path. 2016-12-13 10:06:25 +08:00
static_test.go fix import path. 2016-12-13 10:06:25 +08:00

README.md

static middleware

Build Status 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

package main

import (
	"fmt"
	"time"

	"github.com/gin-contrib/cache"
	"github.com/gin-contrib/cache/persistence"
	"gopkg.in/gin-gonic/gin.v1"
)

func main() {
	r := gin.Default()

	store := persistence.NewInMemoryStore(time.Second)
	// Cached Page
	r.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong "+fmt.Sprint(time.Now().Unix()))
	})

	r.GET("/cache_ping", cache.CachePage(store, time.Minute, func(c *gin.Context) {
		c.String(200, "pong "+fmt.Sprint(time.Now().Unix()))
	}))

	// Listen and Server in 0.0.0.0:8080
	r.Run(":8080")
}