Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶ added in v0.3.1
type Format struct {
// contains filtered or unexported fields
}
Format is a struct that contains two formatters, one for text and one for JSON.
func NewFormat ¶ added in v0.3.1
func NewFormat() *Format
NewFormat creates a new instance of Format struct.
func (*Format) FormatForFile ¶ added in v0.3.1
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 ¶ added in v0.3.1
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 ¶ added in v0.3.1
type JSONFormat struct {
// contains filtered or unexported fields
}
JSONFormat is a struct that contains two colorjson formatters for request and response.
func NewJSONFormat ¶ added in v0.3.1
func NewJSONFormat() *JSONFormat
NewJSONFormat creates a new instance of JSONFormat and returns a pointer to it.
func (*JSONFormat) FormatForFile ¶ added in v0.3.1
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 ¶ added in v0.3.1
func (jf *JSONFormat) FormatRequest(data any) (string, error)
FormatRequest formats the given data as a JSON string using the request formatter.
func (*JSONFormat) FormatResponse ¶ added in v0.3.1
func (jf *JSONFormat) FormatResponse(data any) (string, error)
FormatResponse formats the given data as a JSON string using the response formatter.
type TextFormat ¶ added in v0.3.1
type TextFormat struct {
// contains filtered or unexported fields
}
TextFormat is a struct that holds the color for request and response
func NewTextFormat ¶ added in v0.3.1
func NewTextFormat() *TextFormat
NewTextFormat creates a new instance of TextFormat
func (*TextFormat) FormatForFile ¶ added in v0.3.1
func (tf *TextFormat) FormatForFile(data string) (string, error)
FormatForFile formats the data for file and returns it as a string
func (*TextFormat) FormatRequest ¶ added in v0.3.1
func (tf *TextFormat) FormatRequest(data string) (string, error)
FormatRequest formats the request data and returns it as a string
func (*TextFormat) FormatResponse ¶ added in v0.3.1
func (tf *TextFormat) FormatResponse(data string) (string, error)
FormatResponse formats the response data and returns it as a string