ginzip/example/main.go
Theta-Dev ed0a05df42
All checks were successful
continuous-integration/drone Build is passing
Initial commit
2021-12-17 14:05:22 +01:00

29 lines
579 B
Go

package main
import (
"code.thetadev.de/TSGRain/ginzip"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
options := ginzip.DefaultOptions()
options.BrotliLevel = ""
options.GzipLevel = ""
ui := router.Group("/", ginzip.New(ginzip.DefaultOptions()))
ui.GET("/", getTestHandler("Hello World (should be compressed)"))
api := router.Group("/api")
api.GET("/", getTestHandler("Hello API (should be uncompressed)"))
_ = router.Run(":8080")
}
func getTestHandler(msg string) gin.HandlerFunc {
return func(c *gin.Context) {
c.String(200, msg)
}
}