Documentation ¶
Index ¶
- func AppendPrefix(prefix string, hh http.Handler) http.Handler
- func CopyMultipartFile(file *multipart.FileHeader, dst io.Writer) error
- func Dir(root string, browsable ...bool) http.FileSystem
- func FS(fsys fs.FS, browsable ...bool) http.FileSystem
- func FileServer(prefix string, hfs http.FileSystem, filePath string) http.Handler
- func FixedModTimeFS(hfs http.FileSystem, mt time.Time) http.FileSystem
- func IsStatusClientError(status int) bool
- func IsStatusServerError(status int) bool
- func NewHeaderWriter(w http.ResponseWriter, key, value string) http.ResponseWriter
- func NewHeadersWriter(w http.ResponseWriter, h map[string]string) http.ResponseWriter
- func NoRedirect(req *http.Request, via []*http.Request) error
- func ParseList(value string) []string
- func ParsePairs(value string) map[string]string
- func ReadMultipartFile(file *multipart.FileHeader) ([]byte, error)
- func SaveMultipartFile(file *multipart.FileHeader, dst string) error
- func SetAttachmentHeader(header http.Header, filename string)
- func URLReplace(src, des string, hh http.Handler) http.Handler
- type MultipartWriter
- func (mw *MultipartWriter) CreateFormFile(fieldname, filename string) (io.Writer, error)
- func (mw *MultipartWriter) WriteFields(fields url.Values) error
- func (mw *MultipartWriter) WriteFile(fieldname, filename string) error
- func (mw *MultipartWriter) WriteFileData(fieldname, filename string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendPrefix ¶
AppendPrefix returns a handler that serves HTTP requests by appending the given prefix from the request URL's Path (and RawPath if set) and invoking the handler hh.
func CopyMultipartFile ¶ added in v1.0.13
func CopyMultipartFile(file *multipart.FileHeader, dst io.Writer) error
CopyMultipartFile read multipart file to the specific buffer 'dst'.
func Dir ¶
func Dir(root string, browsable ...bool) http.FileSystem
Dir returns a http.FileSystem that can be used by http.FileServer(). if browsable == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
func FS ¶
func FS(fsys fs.FS, browsable ...bool) http.FileSystem
FS returns a http.FileSystem that can be used by http.FileServer(). if browsable == true, then it works the same as http.FS() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
func FileServer ¶ added in v1.0.13
func FixedModTimeFS ¶
func FixedModTimeFS(hfs http.FileSystem, mt time.Time) http.FileSystem
FixedModTimeFS returns a FileSystem with fixed ModTime
func IsStatusClientError ¶ added in v1.0.26
IsStatusClientError check status is client side error (400-499)
func IsStatusServerError ¶ added in v1.0.26
IsStatusServerError check status is server side error (500-599)
func NewHeaderWriter ¶ added in v1.0.12
func NewHeaderWriter(w http.ResponseWriter, key, value string) http.ResponseWriter
NewHeaderWriter create a http.ResponseWriter to append on WriteHeader(statusCode int). if statusCode != 200, header will not append. a existing header will not be overwriten.
func NewHeadersWriter ¶ added in v1.0.12
func NewHeadersWriter(w http.ResponseWriter, h map[string]string) http.ResponseWriter
NewHeadersWriter create a http.ResponseWriter to append on WriteHeader(statusCode int). if statusCode != 200, header will not append. a existing header will not be overwriten.
func NoRedirect ¶ added in v1.0.12
NoRedirect just return http.ErrUseLastResponse. set http.Client.CheckRedirect to disable auto redirect. Example: http.Client{ChecRedirect: httpx.NoRedirect }
func ParseList ¶
ParseList parses a comma-separated list of values as described by RFC 2068 and returns list elements.
Lifted from https://code.google.com/p/gorilla/source/browse/http/parser/parser.go which was ported from urllib2.parse_http_list, from the Python standard library.
func ParsePairs ¶
ParsePairs extracts key/value pairs from a comma-separated list of values as described by RFC 2068 and returns a map[key]value. The resulting values are unquoted. If a list element doesn't contain a "=", the key is the element itself and the value is an empty string.
Lifted from https://code.google.com/p/gorilla/source/browse/http/parser/parser.go
func ReadMultipartFile ¶ added in v1.0.13
func ReadMultipartFile(file *multipart.FileHeader) ([]byte, error)
ReadMultipartFile read multipart file and return it's content []byte.
func SaveMultipartFile ¶ added in v1.0.13
func SaveMultipartFile(file *multipart.FileHeader, dst string) error
SaveMultipartFile save multipart file to the specific local file 'dst'.
func SetAttachmentHeader ¶ added in v1.0.10
SetAttachmentHeader set header Content-Disposition: attachment; filename=...
Types ¶
type MultipartWriter ¶
func NewMultipartWriter ¶
func NewMultipartWriter(w io.Writer) *MultipartWriter
func (*MultipartWriter) CreateFormFile ¶
func (mw *MultipartWriter) CreateFormFile(fieldname, filename string) (io.Writer, error)
func (*MultipartWriter) WriteFields ¶
func (mw *MultipartWriter) WriteFields(fields url.Values) error
WriteFields calls WriteField and then writes the given fields values.
func (*MultipartWriter) WriteFile ¶
func (mw *MultipartWriter) WriteFile(fieldname, filename string) error
WriteFile calls CreateFormFile and then writes the given file.
func (*MultipartWriter) WriteFileData ¶
func (mw *MultipartWriter) WriteFileData(fieldname, filename string, data []byte) error
WriteFileData calls CreateFormFile and then writes the given file data.