Code Monkey home page Code Monkey logo

size's People

Contributors

appleboy avatar dependabot[bot] avatar gabstv avatar jsloyer avatar menduo avatar tebeka avatar thinkerou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

size's Issues

Middleware should not write response body

Hi there, thanks for building this!

This middleware works as expected, the only issue I'm experiencing is that the request body is written as part of the middleware func:

ctx.String(http.StatusRequestEntityTooLarge, "request too large")

I'm trying to build an API where every response is JSON- even errors like this. What do you suggest? My response body ends up looking like:

request too large{"error":"HTTP request too large"}

Thanks in advance.

上传文件时无法返回信息

你好,我用了这个中间件,在上传大文件的时候会在服务端报错,客户端收不到任何信息

package main

import (
	"net/http"

	limits "github.com/gin-contrib/size"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.Use(limits.RequestSizeLimiter(10))
	r.POST("/", handler)
	_ = r.Run(":8080")
}

func handler(ctx *gin.Context) {
	if file, err := ctx.FormFile("file"); err != nil {
		ctx.JSON(http.StatusOK, gin.H{"msg": "fail: " + err.Error()})
	} else {
		ctx.JSON(http.StatusOK, gin.H{"msg": "ok: " + file.Filename})
	}
}

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.