response

package module
v0.0.0-...-e5575d6 Latest Latest
Warning

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

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

Documentation

Overview

Package response wraps the functionality of the default response in the csp platform (see openapi.yaml file) and all other responses (interfaces)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(w http.ResponseWriter, r *http.Request, status int, payload interface{})

With returns a response with a payload to a client

func WithError

func WithError(w http.ResponseWriter, r *http.Request, status int, err error)

WithError returns a error response to a client

Types

type ComponentError

type ComponentError struct {
	Code  int    `json:"code,omitempty"`
	Error string `json:"error,omitempty"`
}

ComponentError represents all the pit error infos if an error appears

type ErrorResponse

type ErrorResponse struct {
	Success        bool           `json:"success,omitempty"`
	ComponentError ComponentError `json:"componentError,omitempty"`
}

ErrorResponse represents the structure of a error JSON response

type SuccessResponse

type SuccessResponse struct {
	Success bool        `json:"success"`
	Payload interface{} `json:"payload"`
}

SuccessResponse represents the structure of a successful JSON response

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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