Documentation
¶
Overview ¶
Package spond lives to facilitate communication between server and web via JSON structures.
Index ¶
- type Spond
- func (s *Spond) AppendCode(code response.StatusCode, message string) error
- func (s *Spond) BuildError(code response.StatusCode, title, message string) response.ErrorResponse
- func (s *Spond) SendResponseError(c *gin.Context, rsp response.ErrorResponse)
- func (s *Spond) SendResponseSuccess(c *gin.Context, status response.StatusCode, successResponse any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Spond ¶
type Spond struct {
// contains filtered or unexported fields
}
func NewSpond ¶
func NewSpond() *Spond
For initialization struct Spond Usage example spond:=NewSpond() spond.SendResponseSuccess(c, spond.OK, nil)
func (*Spond) AppendCode ¶
func (s *Spond) AppendCode(code response.StatusCode, message string) error
AppendCode adds a new status code and message to the statusMessages card. If the code already exists, returns the errorAppendCode error.
func (*Spond) BuildError ¶
func (s *Spond) BuildError(code response.StatusCode, title, message string) response.ErrorResponse
BuildError forms an error structure for responding to the client. If the input parameters do not pass validation, it returns an error with the UnprocessableEntity code.
func (*Spond) SendResponseError ¶
func (s *Spond) SendResponseError(c *gin.Context, rsp response.ErrorResponse)
SendResponseError sends the error to the client as JSON via gin.Context. rsp — structure with error details.
func (*Spond) SendResponseSuccess ¶
func (s *Spond) SendResponseSuccess(c *gin.Context, status response.StatusCode, successResponse any)
SendResponseSuccess sends a successful JSON response via gin.Context. status is the response status, SuccessResponse is the payload for the client.