MCPcopy Create free account
hub / github.com/kataras/iris / ServeContentWithRate

Method ServeContentWithRate

context/context.go:5448–5458  ·  view source on GitHub ↗

ServeContentWithRate same as `ServeContent` but it can throttle the speed of reading and though writing the "content" to the client.

(content io.ReadSeeker, filename string, modtime time.Time, limit float64, burst int)

Source from the content-addressed store, hash-verified

5446// ServeContentWithRate same as `ServeContent` but it can throttle the speed of reading
5447// and though writing the "content" to the client.
5448func (ctx *Context) ServeContentWithRate(content io.ReadSeeker, filename string, modtime time.Time, limit float64, burst int) {
5449 if limit > 0 {
5450 content = &rateReadSeeker{
5451 ReadSeeker: content,
5452 ctx: ctx.request.Context(),
5453 limiter: rate.NewLimiter(rate.Limit(limit), burst),
5454 }
5455 }
5456
5457 http.ServeContent(ctx.writer, ctx.request, filename, modtime, content)
5458}
5459
5460// ServeFile replies to the request with the contents of the named
5461// file or directory.

Callers 3

ServeContentMethod · 0.95
ServeFileWithRateMethod · 0.95
FileServerFunction · 0.80

Calls 2

ContextMethod · 0.80
ServeContentMethod · 0.80

Tested by

no test coverage detected