Documentation ¶
Index ¶
- Variables
- func Init(d bool)
- type FileResponseEntry
- type Response
- func BadRequest(err error) Response
- func Conflict(err error) Response
- func ErrorResponse(code int, msg string) Response
- func FileResponse(r *http.Request, files []FileResponseEntry, headers map[string]string, ...) Response
- func Forbidden(err error) Response
- func ForwardedResponse(client lxd.InstanceServer, request *http.Request) Response
- func InternalError(err error) Response
- func NotFound(err error) Response
- func NotImplemented(err error) Response
- func PreconditionFailed(err error) Response
- func SmartError(err error) Response
- func SyncResponse(success bool, metadata interface{}) Response
- func SyncResponseETag(success bool, metadata interface{}, etag interface{}) Response
- func SyncResponseHeaders(success bool, metadata interface{}, headers map[string]string) Response
- func SyncResponseLocation(success bool, metadata interface{}, location string) Response
- func SyncResponseRedirect(address string) Response
- func Unavailable(err error) Response
Constants ¶
This section is empty.
Variables ¶
var EmptySyncResponse = &syncResponse{success: true, metadata: make(map[string]interface{})}
EmptySyncResponse represents an empty syncResponse.
Functions ¶
Types ¶
type FileResponseEntry ¶
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 ¶
type Response interface { Render(w http.ResponseWriter) error String() string }
Response represents an API response
func BadRequest ¶
BadRequest returns a bad request response (400) with the given error.
func ErrorResponse ¶
ErrorResponse returns an error response with the given code and msg.
func FileResponse ¶
func FileResponse(r *http.Request, files []FileResponseEntry, headers map[string]string, removeAfterServe bool) Response
FileResponse returns a new file response.
func ForwardedResponse ¶
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 ¶
InternalError returns an internal error response (500) with the given error.
func NotImplemented ¶
NotImplemented returns a not implemented response (501) with the given error.
func PreconditionFailed ¶
PreconditionFailed returns a precondition failed response (412) with the given error.
func SmartError ¶
SmartError returns the right error message based on err.
func SyncResponse ¶
SyncResponse returns a new syncResponse with the success and metadata fields set to the provided values.
func SyncResponseETag ¶
SyncResponseETag returns a new syncResponse with an etag.
func SyncResponseHeaders ¶
SyncResponseHeaders returns a new syncResponse with headers.
func SyncResponseLocation ¶
SyncResponseLocation returns a new syncResponse with a location.
func SyncResponseRedirect ¶
SyncResponseRedirect returns a new syncResponse with a location, indicating a permanent redirect.
func Unavailable ¶
Unavailable return an unavailable response (503) with the given error.