sizelimit

package module
v0.0.0-...-729a4c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 10 Imported by: 0

README

krakend-sizelimit

The sizelimit middleware can be used to limit the request size of incoming requests.

Installation

To install sizelimit from GitHub:

go get -u github.com/kivra/krakend-sizelimit@<commit hash>

Then add sizelimit to the KrakenD handler_factory chain:

handlerFactory = sizelimit.HandlerFactory(handlerFactory)

Usage

Add sizelimit to the endpoint's extra_config and define the maximum request body size. If no unit is specified, max_size is assumed to have unit bytes. Other units can be specified explictly: B (bytes, same as no unit), kB, MB, GB, TB.

"endpoints": [
  {
    "endpoint": "/test",
    "extra_config": {
      "kivra/sizelimit": {
        "max_size": "10MB"
      }
    },
    "backend": [ "..." ]
  }
]

Documentation

Index

Constants

View Source
const Namespace = "kivra/sizelimit"

Variables

This section is empty.

Functions

func ExceedsSizeLimit

func ExceedsSizeLimit(c *gin.Context, limit int64) bool

func LimiterFactory

func LimiterFactory(limit int64, handlerFunc gin.HandlerFunc) gin.HandlerFunc

func ParseMaxSize

func ParseMaxSize(cfg *Config) int64

Types

type Config

type Config struct {
	MaxSize string `json:"max_size"`
}

type ConfigInternal

type ConfigInternal struct {
	MaxSize int64 `json:"max_size"`
}

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) (*ConfigInternal, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL