response

package
v0.0.0-...-ab2e698 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: CC0-1.0 Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRequestBodyResponse is a response indicating there was no request body.
	ErrNoRequestBodyResponse = NewErrorResponse(http.StatusBadRequest, "No Request Body")

	// ErrUnprocessableEntityResponse is a response indicating the service instance not async
	ErrUnprocessableEntityResponse = NewErrorResponse(http.StatusUnprocessableEntity, "This Service Instance requires client support for asynchronous binding operations")
)
View Source
var (
	// SuccessCreateResponse represents the response that all successful instance creations should return.
	SuccessCreateResponse = newSuccessResponse(http.StatusCreated, SuccessCreateResponseType, "The instance was created")
	// SuccessAcceptedResponse represents the response that all successful instance acceptions should return.
	SuccessAcceptedResponse = newSuccessResponse(http.StatusAccepted, SuccessAcceptedResponseType, "The operation was accepted")
	// SuccessDeleteResponse represents the response that all successful instance deletions should return.
	SuccessDeleteResponse = newSuccessResponse(http.StatusOK, SuccessDeleteResponseType, "The instance was deleted")
)

Functions

This section is empty.

Types

type Response

type Response interface {
	GetStatusCode() int
	GetResponseType() Type
}

Response represents the common data for all types of responses to have and implement.

func NewAsyncOperationResponse

func NewAsyncOperationResponse(operation string) Response

If a broker has an async operation ( create, modify, delete, bind) and wants to return an "operation" they should use this Otherwise they can return SuccessAcceptedResponse

func NewErrorResponse

func NewErrorResponse(statusCode int, description string) Response

NewErrorResponse is the constructor for an errorResponse.

func NewSuccessBindResponse

func NewSuccessBindResponse(credentials map[string]string) Response

NewSuccessBindResponse is the constructor for a successBindResponse.

func NewSuccessLastOperation

func NewSuccessLastOperation(state string, description string) Response

NewSuccessLastOperation for async responses

type Type

type Type string

Type indicates the type of response. Nice for debug situations.

var (
	// SuccessCreateResponseType represents a response for a successful instance creation.
	SuccessCreateResponseType Type = "success_create"
	// SuccessAcceptedResponseType represents a response for a successful instance creation.
	SuccessAcceptedResponseType Type = "success_accept"
	// SuccessLastOperationResponseType represents a response for a successful last operation.
	SuccessLastOperationResponseType Type = "success_lastoperation"
	// SuccessBindResponseType represents a response for a successful instance binding.
	SuccessBindResponseType Type = "success_bind"
	// SuccessDeleteResponseType represents a response for a successful instance deletion.
	SuccessDeleteResponseType Type = "success_delete"
	// ErrorResponseType represents a response for an error.
	ErrorResponseType Type = "error"
)

These contain the list of response types. Useful for debug situations.

Jump to

Keyboard shortcuts

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