lxd: github.com/lxc/lxd/lxd/response Index | Files

package response

import "github.com/lxc/lxd/lxd/response"


Package Files

response.go smart_linux.go


var EmptySyncResponse = &syncResponse{success: true, metadata: make(map[string]interface{})}

EmptySyncResponse represents an empty syncResponse.

func Init Uses

func Init(d bool)

Init sets the debug variable to the provided value.

type FileResponseEntry Uses

type FileResponseEntry struct {
    Identifier string
    Path       string
    Filename   string
    Buffer     []byte /* either a path or a buffer must be provided */

FileResponseEntry represents a file response entry.

type Response Uses

type Response interface {
    Render(w http.ResponseWriter) error
    String() string

Response represents an API response

func BadRequest Uses

func BadRequest(err error) Response

BadRequest returns a bad request response (400) with the given error.

func Conflict Uses

func Conflict(err error) Response

Conflict returns a conflict response (409) with the given error.

func ErrorResponse Uses

func ErrorResponse(code int, msg string) Response

ErrorResponse returns an error response with the given code and msg.

func FileResponse Uses

func FileResponse(r *http.Request, files []FileResponseEntry, headers map[string]string, removeAfterServe bool) Response

FileResponse returns a new file response.

func Forbidden Uses

func Forbidden(err error) Response

Forbidden returns a forbidden response (403) with the given error.

func ForwardedResponse Uses

func ForwardedResponse(client lxd.InstanceServer, request *http.Request) Response

ForwardedResponse takes a request directed to a node and forwards it to another node, writing back the response it gegs.

func InternalError Uses

func InternalError(err error) Response

InternalError returns an internal error response (500) with the given error.

func NotFound Uses

func NotFound(err error) Response

NotFound returns a not found response (404) with the given error.

func NotImplemented Uses

func NotImplemented(err error) Response

NotImplemented returns a not implemented response (501) with the given error.

func PreconditionFailed Uses

func PreconditionFailed(err error) Response

PreconditionFailed returns a precondition failed response (412) with the given error.

func SmartError Uses

func SmartError(err error) Response

SmartError returns the right error message based on err.

func SyncResponse Uses

func SyncResponse(success bool, metadata interface{}) Response

SyncResponse returns a new syncResponse with the success and metadata fields set to the provided values.

func SyncResponseETag Uses

func SyncResponseETag(success bool, metadata interface{}, etag interface{}) Response

SyncResponseETag returns a new syncResponse with an etag.

func SyncResponseHeaders Uses

func SyncResponseHeaders(success bool, metadata interface{}, headers map[string]string) Response

SyncResponseHeaders returns a new syncResponse with headers.

func SyncResponseLocation Uses

func SyncResponseLocation(success bool, metadata interface{}, location string) Response

SyncResponseLocation returns a new syncResponse with a location.

func SyncResponseRedirect Uses

func SyncResponseRedirect(address string) Response

SyncResponseRedirect returns a new syncResponse with a location, indicating a permanent redirect.

func Unavailable Uses

func Unavailable(err error) Response

Unavailable return an unavailable response (503) with the given error.

Package response imports 17 packages (graph) and is imported by 7 packages. Updated 2020-04-06. Refresh now. Tools for package owners.