httputils

package
v1.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 3 Imported by: 0

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]) Write

func (w *FakeWriter[DST]) Write(b []byte) (int, error)

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL