response

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWith

func AbortWith(c *gin.Context, status int, message string)

AbortWith writes an error envelope and aborts the handler chain. Use this inside middleware or when you need to stop further processing.

response.AbortWith(c, http.StatusUnauthorized, "missing token")

func Data

func Data(c *gin.Context, args ...any)

Data writes a 200 (or any 2xx) success envelope.

response.OK(c, gin.H{"id": 42})
response.OK(c, http.StatusCreated, createdUser)

func Error

func Error(c *gin.Context, status int, message string)

Error writes an error envelope. The data field will be null.

response.Fail(c, http.StatusNotFound, "user not found")

Types

type Body

type Body struct {
	Data  any     `json:"data"`
	Error *string `json:"error"`
}

Body is the top-level JSON shape returned by every endpoint.

Jump to

Keyboard shortcuts

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