Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AllowedPunctuationInFilenames lists the punctuation characters that are tolerated // when converting URLs to filenames. This is initialised to a string appropriate for // the current OS. AllowedPunctuationInFilenames = nonWindowsPunct // FilenameTimestampFormat is the time format used for filenames containing a timestamp. FilenameTimestampFormat = "2006-01-02_15-04-05.000" )
var PrettyIndent = ""
PrettyIndent sets the indentation used to pretty-print JSON and XML body files, when these are written (see WithHeadersAndBodies and LongBodyThreshold). When non-blank, PrettyIndent
var WriteJSONFile = func(out io.Writer, body []byte) error { if len(PrettyIndent) == 0 { return writePlainText(out, body) } var data interface{} err := json.NewDecoder(bytes.NewReader(body)).Decode(&data) if err != nil { return writePlainText(out, body) } var enc = json.NewEncoder(out) enc.SetIndent("", PrettyIndent) return enc.Encode(data) }
WriteJSONFile is a function to write JSON files. If PrettyIndent is non-blank, the result is pretty-printed JSON; otherwise, it is verbatim.
An alternative function may be substituted if required.
var WriteXMLFile = func(out io.Writer, body []byte) error { if len(PrettyIndent) == 0 { return writePlainText(out, body) } xml := xmlfmt.FormatXML(string(body), "", PrettyIndent) if strings.HasPrefix(xml, xmlfmt.NL) { xml = xml[len(xmlfmt.NL):] } _, err := strings.NewReader(xml).WriteTo(out) return err }
WriteXMLFile is a function to write XML files. If PrettyIndent is non-blank, the result is pretty-printed XML; otherwise, it is verbatim.
An alternative function may be substituted if required.
Functions ¶
func FilenameTimestamp ¶
func PrettyPrint ¶
PrettyPrint writes a body to a writer (usually a file). Pretty printing is implemented via transcoding for JSON and XML only. All other file times are written verbatim.
func UrlToFilename ¶
Types ¶
This section is empty.