Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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")
}

About

Limit size of POST requests for Gin framework

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.