xhttp

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BusinessCodeOK represents the business code for success.
	BusinessCodeOK = 0
	// BusinessMsgOk represents the business message for success.
	BusinessMsgOk = "ok"
)

Variables

This section is empty.

Functions

func JsonBaseResponseCtx

func JsonBaseResponseCtx(ctx context.Context, w http.ResponseWriter, v any)

JsonBaseResponseCtx writes v into w with http.StatusOK.

Types

type BaseResponse

type BaseResponse[T any] struct {
	// Code represents the business code, not the http xstatus code.
	Code int ` json:"code" xml:"code"`
	// Msg represents the business message, if Code = BusinessCodeOK,
	// and Msg is empty, then the Msg will be set to BusinessMsgOk.
	Message string `json:"message" xml:"message"`
	// Data represents the business data.
	Data T `json:"data,omitempty" xml:"data,omitempty"`
}

BaseResponse is the base response struct.

Jump to

Keyboard shortcuts

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