Skip to content
Limit size of POST requests for Gin framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.gitignore feat: add govendor Mar 26, 2017
.travis.yml remove 1.7 from travis Mar 1, 2019
LICENSE Initial commit Mar 26, 2017
README.md Change to RequestSizeLimiter & better tests (#4) Feb 16, 2018
go.mod
go.sum feat: enable go module Dec 27, 2018
size.go Change to RequestSizeLimiter & better tests (#4) Feb 16, 2018
size_test.go Change to RequestSizeLimiter & better tests (#4) Feb 16, 2018

README.md

size

Build Status codecov Go Report Card GoDoc Join the chat at https://gitter.im/gin-gonic/gin

Limit size of POST requests for Gin framework

Example

package main

import (
	"net/http"
	"github.com/gin-contrib/size"
	"github.com/gin-gonic/gin"
)

func handler(ctx *gin.Context) {
	val := ctx.PostForm("b")
	if len(ctx.Errors) > 0 {
		return
	}
	ctx.String(http.StatusOK, "got %s\n", val)
}

func main() {
	rtr := gin.Default()
	rtr.Use(limits.RequestSizeLimiter(10))
	rtr.POST("/", handler)
	rtr.Run(":8080")
}
You can’t perform that action at this time.