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