Documentation
¶
Index ¶
- func DeepCopyRequest(r *http.Request, maxBodyMB int) (*http.Request, error)
- func DeepCopyResponse(r *http.Response, maxBodyMB int) (*http.Response, error)
- func DownloadFileByConcurrent(url string, outputPath string, num_workers int) error
- func PreprocessInput(input string) string
- func PrintCHIRoutes(r *chi.Mux)
- func PtrBool(b bool) *bool
- func PtrBytes(b []byte) *[]byte
- func PtrFloat32(f float32) *float32
- func PtrFloat64(f float64) *float64
- func PtrInt(i int) *int
- func PtrInt8(i int8) *int8
- func PtrInt16(i int16) *int16
- func PtrInt32(i int32) *int32
- func PtrInt64(i int64) *int64
- func PtrString(s string) *string
- func PtrTime(t time.Time) *time.Time
- func PtrUUID(id uuid.UUID) *uuid.UUID
- func PtrUint(u uint) *uint
- func PtrUint8(u uint8) *uint8
- func PtrUint16(u uint16) *uint16
- func PtrUint32(u uint32) *uint32
- func PtrUint64(u uint64) *uint64
- func ReturnCSVResponse(w http.ResponseWriter, filename string, headers []string, rows [][]string)
- func ReturnErrorResponse(w http.ResponseWriter, code int, errorMsg string)
- func ReturnJsonResponse(w http.ResponseWriter, code int, payload interface{})
- func SafelyReadBody(body io.ReadCloser, maxBodyMB *int) (data []byte, err error)
- func StreamDownloadHandler(w http.ResponseWriter, reader io.Reader, filename string, contentType string, ...)
- type UniversalResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepCopyRequest ¶ added in v0.53.0
DeepCopyRequest creates a deep copy of the HTTP request r, including the body content. It limits the body size to maxBodyMB MB. If the body size exceeds maxBodyMB MB, it returns an error.
func DeepCopyResponse ¶ added in v0.53.0
DeepCopyResponse creates a deep copy of the HTTP response r, including the body content. It limits the body size to maxBodyMB MB. If the body size exceeds maxBodyMB MB, it returns an error. Note: Request and TLS fields are shared (not deep copied) as they are typically read-only.
func DownloadFileByConcurrent ¶ added in v0.29.0
DownloadFileByConcurrent 多Goroutine分片下载文件(自动保留原始后缀) 参数说明:
url: 下载URL(你的GetApp接口地址,string) outputPath: 保存目录/文件路径(string): - 若为目录(如./downloads/),自动拼接原始文件名; - 若为文件路径(如./app.exe),直接使用该路径; num_workers: 并发数(必须>0,int)
func PreprocessInput ¶
func PrintCHIRoutes ¶ added in v0.20.0
func PtrFloat32 ¶
func PtrFloat64 ¶
func ReturnCSVResponse ¶
func ReturnCSVResponse(w http.ResponseWriter, filename string, headers []string, rows [][]string)
ReturnCSVResponse 返回 CSV 格式的响应
func ReturnErrorResponse ¶
func ReturnErrorResponse(w http.ResponseWriter, code int, errorMsg string)
func ReturnJsonResponse ¶
func ReturnJsonResponse(w http.ResponseWriter, code int, payload interface{})
ReturnJsonResponse is a helper function to send JSON responses
func SafelyReadBody ¶ added in v0.53.0
func SafelyReadBody(body io.ReadCloser, maxBodyMB *int) (data []byte, err error)
SafelyReadBody reads the body (io.ReadCloser) safely, limiting the size to maxBodyMB MB. It returns the body content as a byte slice and any error that occurred during the read operation. It will close the body after reading.