response

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write added in v0.0.17

func Write(w http.ResponseWriter, opts ...Option) error

Write sends the response to the client. The `Response` fields can be overridden by passing variadic `opts` ("Functional Options") arguments. If no options are given, an empty `200` response is used.

Types

type Option added in v0.0.16

type Option func(*Response)

Option helps overriding/adding response options to the current response.

func Code added in v0.0.16

func Code(code int) Option

Code sets status code.

func Error

func Error(action string, message string, errors map[string]string) Option

Error represents "failure" response.

func Headers added in v0.0.16

func Headers(headers map[string]string) Option

Headers adds headers.

func Success

func Success(action string, data interface{}, meta interface{}) Option

Success represents "successful" response.

type Response added in v0.0.16

type Response struct {
	Action  string            `json:"action,omitempty"`
	Data    interface{}       `json:"data,omitempty"`
	Meta    interface{}       `json:"meta,omitempty"`
	Message string            `json:"message,omitempty"`
	Errors  map[string]string `json:"errors,omitempty"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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