Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, err error, data interface{})

WriteResponse write an error or the response data into http response body. It use errors.ParseCoder to parse any error into errors.Coder errors.Coder contains error code, user-safe error message and http status code.

Types

type ErrResponse

type ErrResponse struct {
	// Code defines the business error code.
	Code int `json:"code"`

	// Message contains the detail of this message.
	// This message is suitable to be exposed to external
	Message string `json:"message"`

	// Reference returns the reference document which maybe useful to solve this error.
	Reference string `json:"reference,omitempty"`
}

ErrResponse defines the return messages when an error occurred. Reference will be omitted if it does not exist. swagger:model

type RawHttpHandler

type RawHttpHandler func(w http.ResponseWriter, r *http.Request)

RawHttpHandler raw http handler.

Jump to

Keyboard shortcuts

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