chore(deps): add gin-contrib/gzip for response compression
Add `github.com/gin-contrib/gzip` to the module dependencies and update `go.sum` with the newly introduced transitive dependencies, preparing the Gin server for gzip-compressed responses.chore(deps): add gin-contrib/gzip for response compression Add `github.com/gin-contrib/gzip` to the module dependencies and update `go.sum` with the newly introduced transitive dependencies, preparing the Gin server for gzip-compressed responses.
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
package server
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-contrib/gzip"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Run(addr string) error {
|
||||
router := gin.Default()
|
||||
router.LoadHTMLGlob("templates/*.html")
|
||||
|
||||
router.GET("/", func(ctx *gin.Context) {
|
||||
ctx.String(200, "ok")
|
||||
ctx.HTML(http.StatusOK, "index.html", gin.H{})
|
||||
})
|
||||
|
||||
compressed := router.Group("/", gzip.Gzip(gzip.DefaultCompression))
|
||||
compressed.Static("/static", "./static")
|
||||
|
||||
return router.Run(addr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user