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)
| 5446 | // ServeContentWithRate same as `ServeContent` but it can throttle the speed of reading |
| 5447 | // and though writing the "content" to the client. |
| 5448 | func (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. |
no test coverage detected