Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONHttpError ¶
func JSONHttpError(w http.ResponseWriter, errStr string, status int)
Returns a JSON error response with the following structure:
{
"status": "error",
"message": "Error message"
}
It will also set the HTTP status code to the provided status code.
Types ¶
type FakeWriter ¶
type FakeWriter[DST io.ReadWriter] struct { WriteTo DST Headers http.Header StatusCode int }
func NewFakeWriter ¶
func NewFakeWriter[DST io.ReadWriter](dst DST) *FakeWriter[DST]
func (*FakeWriter[DST]) CopyTo ¶
func (w *FakeWriter[DST]) CopyTo(wr http.ResponseWriter, flags ...WriterCopyFlag) (int64, error)
func (*FakeWriter[DST]) Header ¶
func (w *FakeWriter[DST]) Header() http.Header
func (*FakeWriter[DST]) Unwrap ¶
func (w *FakeWriter[DST]) Unwrap() DST
func (*FakeWriter[DST]) WriteHeader ¶
func (w *FakeWriter[DST]) WriteHeader(statusCode int)
type WriterCopyFlag ¶
type WriterCopyFlag int
const ( FlagCopyHeader WriterCopyFlag = iota << 1 FlagCopyBody FlagCopyStatus FlagCopyAll = FlagCopyHeader | FlagCopyBody | FlagCopyStatus )
Click to show internal directories.
Click to hide internal directories.