Serving data from Context

Serving data from Context

SendFile(filename string, destinationName string) error
SendFileWithRate(src, destName string, limit float64, burst int) error

Usage

Force-Send a file to the client:

func handler(ctx iris.Context) {
    src := "./files/first.zip"
    ctx.SendFile(src, "client.zip")
}

Limit download speed to ~50Kb/s with a burst of 100KB:

func handler(ctx iris.Context) {
    src := "./files/big.zip"
    // optionally, keep it empty to resolve the filename based on the "src".
    dest := "" 

    limit := 50.0 * iris.KB
    burst := 100 * iris.KB
    ctx.SendFileWithRate(src, dest, limit, burst)
}
ServeContent(content io.ReadSeeker, filename string, modtime time.Time)
ServeContentWithRate(content io.ReadSeeker, filename string, modtime time.Time, limit float64, burst int)

ServeFile(filename string) error
ServeFileWithRate(filename string, limit float64, burst int) error

Usage

func handler(ctx iris.Context) {
    ctx.ServeFile("./public/main.js")
}