17 lines
452 B
Go
17 lines
452 B
Go
package files
|
|
|
|
import (
|
|
"git.yuntuo.hk/k2safe/go-omni/httpx"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func (h *Handler) Download(c *httpx.Context) error {
|
|
return httpx.WrapHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/octet-stream")
|
|
w.Header().Set("Content-Disposition", `attachment; filename="demo.bin"`)
|
|
_, _ = io.Copy(w, strings.NewReader(strings.Repeat("x", 128<<10)))
|
|
}))(c)
|
|
}
|