Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format struct {
// contains filtered or unexported fields
}
Format is a struct that contains two formatters, one for text and one for JSON.
func (*Format) FormatForFile ¶
FormatForFile formats the given WebSocket message for a file. It first tries to parse the message data as JSON, and if successful, formats it as JSON. If parsing fails, it formats the message data as plain text.
func (*Format) FormatMessage ¶
FormatMessage formats the given WebSocket message based on its type and data. If the data is a valid JSON, it will be formatted using the JSON formatter. Otherwise, it will be formatted using the text formatter.
type JSONFormat ¶
type JSONFormat struct {
// contains filtered or unexported fields
}
JSONFormat is a struct that contains two colorjson formatters for request and response.
func NewJSONFormat ¶
func NewJSONFormat() *JSONFormat
NewJSONFormat creates a new instance of JSONFormat and returns a pointer to it.
func (*JSONFormat) FormatForFile ¶
func (jf *JSONFormat) FormatForFile(data any) (string, error)
FormatForFile formats the given data as a JSON string using the default json package.
func (*JSONFormat) FormatRequest ¶
func (jf *JSONFormat) FormatRequest(data any) (string, error)
FormatRequest formats the given data as a JSON string using the request formatter.
func (*JSONFormat) FormatResponse ¶
func (jf *JSONFormat) FormatResponse(data any) (string, error)
FormatResponse formats the given data as a JSON string using the response formatter.
type TextFormat ¶
type TextFormat struct {
// contains filtered or unexported fields
}
TextFormat is a struct that holds the color for request and response
func NewTextFormat ¶
func NewTextFormat() *TextFormat
NewTextFormat creates a new instance of TextFormat
func (*TextFormat) FormatForFile ¶
func (tf *TextFormat) FormatForFile(data string) (string, error)
FormatForFile formats the data for file and returns it as a string
func (*TextFormat) FormatRequest ¶
func (tf *TextFormat) FormatRequest(data string) (string, error)
FormatRequest formats the request data and returns it as a string
func (*TextFormat) FormatResponse ¶
func (tf *TextFormat) FormatResponse(data string) (string, error)
FormatResponse formats the response data and returns it as a string