Documentation
¶
Index ¶
- Variables
- func ErrInvalidKey(k string) error
- func ErrMissingKey(k string) error
- func ErrNotFound(k, v string) error
- func HandleErr(w http.ResponseWriter, r *http.Request, err error, code ...int)
- func InitiateWS(cfg config.ConfigInstance, w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
- func LogDebug(r *http.Request) *zerolog.Event
- func LogError(r *http.Request) *zerolog.Event
- func LogInfo(r *http.Request) *zerolog.Event
- func LogWarn(r *http.Request) *zerolog.Event
- func PeriodicWS(cfg config.ConfigInstance, w http.ResponseWriter, r *http.Request, ...)
- func RespondError(w http.ResponseWriter, err error, code ...int)
- func RespondJSON(w http.ResponseWriter, r *http.Request, data any, code ...int) (canProceed bool)
- func WriteBody(w http.ResponseWriter, body []byte)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Get = httpClient.Get Post = httpClient.Post Head = httpClient.Head )
Functions ¶
func ErrInvalidKey ¶
func ErrMissingKey ¶
func ErrNotFound ¶
func HandleErr ¶
HandleErr logs the error and returns an error code to the client. If code is specified, it will be used as the HTTP status code; otherwise, http.StatusInternalServerError is used.
The error is only logged but not returned to the client.
func InitiateWS ¶
func InitiateWS(cfg config.ConfigInstance, w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
func PeriodicWS ¶
func RespondError ¶
func RespondError(w http.ResponseWriter, err error, code ...int)
RespondError returns error details to the client. If code is specified, it will be used as the HTTP status code; otherwise, http.StatusBadRequest is used.
func RespondJSON ¶
func WriteBody ¶
func WriteBody(w http.ResponseWriter, body []byte)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.