Documentation ¶
Index ¶
- func BytesToString(b []byte) string
- func CreateTempFile(data []byte) (string, error)
- func FastStatusCode(resp *FastResponse) int
- func FindNameIterTo(r *qxml.Reader, name string, to string) bool
- func MatchNameIterTo(r *qxml.Reader, namePattern string, toPattern string) bool
- func MaxLineLen(s string) int
- func MaxLineLenWithPrefix(s string, prefix []byte) (string, int)
- func MimeTypeFromURL(u string) (string, string)
- func ParseRelsMap(f *zip.File, preffix string) (map[string]string, error)
- func StringTobytes(s string) []byte
- type FastResponse
- type ReqSetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString converts a byte slice to a string.
It takes a parameter b, which is a byte slice. It returns a string.
This function is implemented using the `unsafe` package to achieve zero cost conversion.
func CreateTempFile ¶
CreateTempFile creates a temporary file and writes the provided data to it.
Parameters:
- data: the data to be written to the file.
Returns:
- string: the absolute path of the created file.
- error: an error if any occurred during the process.
func FastStatusCode ¶
func FastStatusCode(resp *FastResponse) int
FastStatusCode returns fasthttp status code
func FindNameIterTo ¶
FindNameIterTo finds the given name iteratively in the qxml Reader until it reaches the specified end element.
Parameters:
- r: a pointer to the qxml Reader.
- name: the name to search for in the qxml Reader.
- to: the end element name to stop the search.
Returns:
- true if the name is found before reaching the end element, false otherwise.
func MatchNameIterTo ¶
MatchNameIterTo is a function that matches the name pattern and the to pattern iteratively using the given qxml.Reader. It returns true if the name pattern is matched and false if the to pattern is matched or if the end of the reader is reached.
Parameters:
- r: A pointer to a qxml.Reader object
- namePattern: The regular expression pattern to match the name
- toPattern: The regular expression pattern to match the to
Return:
- bool: true if the name pattern is matched, false otherwise
func MaxLineLen ¶
MaxLineLen returns the maximum line length in a given string.
Parameters:
- s: the input string to check for maximum line length.
Return type:
- int: the maximum line length in the given string.
func MaxLineLenWithPrefix ¶
MaxLineLenWithPrefix calculates the maximum line length in a string with a given prefix.
Parameters:
- s: the input string
- prefix: the prefix to add to each line
Returns:
- string: the modified string with the added prefix
- int: the maximum line length (including the prefix)
func MimeTypeFromURL ¶
MimeTypeFromURL returns the MIME type and lowercase file extension from a given URL.
Parameters:
- u(string): The URL from which to extract the MIME type and file extension.
Returns:
- string: The MIME type extracted from the URL.
- string: The file extension extracted from the URL.
func ParseRelsMap ¶
ParseRelsMap parses a zip file and returns a mapping of relationship IDs to target strings.
Parameters:
- f: *zip.File object representing the zip file to parse.
- prefix: string prefix used to construct full part name(target string).
Returns:
- map[string]string: a mapping of relationship IDs to target strings.
- error: an error object indicating any error occurred during parsing.
func StringTobytes ¶
StringTobytes converts a string to a byte slice.
It takes a string parameter `s` and returns a byte slice.
This function is implemented using the `unsafe` package to achieve zero cost conversion.
Types ¶
type FastResponse ¶
func FastGet ¶
func FastGet(u string, reqSetters ...ReqSetter) (*FastResponse, error)
FastGet retrieves a response from the specified URL using the GET method.
Parameters:
- u: The URL to send the GET request to.
- reqSetters: Optional request setters to modify the request before sending.
Returns:
- *FastResponse: A pointer to the FastResponse struct containing the response body and status code.
- error: An error object if the request fails.
func FastPut ¶
func FastPut(u string, reqSetters ...ReqSetter) (*FastResponse, error)
FastPut sends a fast HTTP PUT request to the specified URL with optional request setters.
Parameters:
- u: The URL to send the request to.
- reqSetters: Optional request setters to customize the request before sending.
Returns:
- fastResp: The response from the request containing the response body and status code.
- error: An error if the request fails.
type ReqSetter ¶
func WithBodyStream ¶
WithBodyStream sets the body of the fasthttp request to the given reader and size.
Parameters:
- r: The reader to use as the body of the request.
- size: The size of the body.
Returns:
- ReqSetter: func(req *fasthttp.Request)
func WithHeaders ¶
WithHeaders sets the headers of the request.
Parameters:
- headers: a map of string keys to string values representing the headers to be set.
Returns:
- ReqSetter: func(req *fasthttp.Request)