httputil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(w http.ResponseWriter, status int, code ErrorCode, msg string)

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v interface{})

Types

type APIError

type APIError struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

type ErrorCode

type ErrorCode string
const (
	CodeNotFound    ErrorCode = "NOT_FOUND"
	CodeBadRequest  ErrorCode = "BAD_REQUEST"
	CodeInternal    ErrorCode = "INTERNAL_ERROR"
	CodeUnauth      ErrorCode = "UNAUTHORIZED"
	CodeConflict    ErrorCode = "CONFLICT"
	CodeUnavailable ErrorCode = "UNAVAILABLE"
)

Jump to

Keyboard shortcuts

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