Documentation ¶
Index ¶
- Variables
- func WriteInternalError(w http.ResponseWriter, log string, err error)
- func WriteMany(w http.ResponseWriter, status int, models interface{})
- func WriteOne(w http.ResponseWriter, status int, model interface{})
- func WriteOneError(w http.ResponseWriter, status int, err *jsonapi.ErrorObject)
- type Handler
- func (h *Handler) MachineCreate(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) MachineDelete(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) MachineInfo(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) MachineList(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) Serve(addr string) error
- func (h *Handler) SessionControl(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) SessionCreate(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- func (h *Handler) SessionIO(w http.ResponseWriter, r *http.Request, params httprouter.Params)
- type SessionCreateRequest
- type SessionCreateResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // BadRequestError for badly formatted requests BadRequestError = &jsonapi.ErrorObject{ Code: "bad_request", Title: "Bad Request", Detail: "Your request is not in a valid format", } // InternalServerError for unhandled errors InternalServerError = &jsonapi.ErrorObject{ Code: "internal_server", Title: "Internal server error", Detail: "Unexpected internal error", } // ResourceNotFoundError for non existing resources ResourceNotFoundError = &jsonapi.ErrorObject{ Code: "not_found", Title: "Resource was not found", Detail: "The resource you requested does not exist", } UnauthorizedError = &jsonapi.ErrorObject{ Code: "unauthorized", Title: "Unauthorized", Detail: "The request lacks valid authentication credentials.", } // AccessDeniedError is returned when rqeuested action is not allowed AccessDeniedError = &jsonapi.ErrorObject{ Code: "access_denied", Title: "Access denied", Detail: "You are not allowed to perform the requested action.", } // ValidationFailedError is returned when request did not pass validation ValidationFailedError = &jsonapi.ErrorObject{ Code: "validation_failed", Title: "Request validation failed", } )
View Source
var ( // QuotaExceededError is returned when the machine limit for a user is reached QuotaExceededError = &jsonapi.ErrorObject{ Code: "machine_quota_exceeded", Title: "Machine quota exceeded", Detail: "You have reached your limit of machines you are allowed to create.", } // MachineNameTakenError is returned when the machine name is taken MachineNameTakenError = &jsonapi.ErrorObject{ Code: "machine_name_taken", Title: "Machine name is taken", Detail: "Please choose a different name.", } )
Functions ¶
func WriteInternalError ¶
func WriteInternalError(w http.ResponseWriter, log string, err error)
WriteInternalError logs and returns an internal server error
func WriteMany ¶
func WriteMany(w http.ResponseWriter, status int, models interface{})
WriteMany returns a list of resource objects
func WriteOne ¶
func WriteOne(w http.ResponseWriter, status int, model interface{})
WriteOne returns one resource object
func WriteOneError ¶
func WriteOneError(w http.ResponseWriter, status int, err *jsonapi.ErrorObject)
WriteOneError returns one error object
Types ¶
type Handler ¶
type Handler struct { DB *pg.DB Scheduler scheduler.Scheduler JWTSecret []byte AllowOrigins []string }
Handler stores common types needed by the api
func (*Handler) MachineCreate ¶
func (h *Handler) MachineCreate(w http.ResponseWriter, r *http.Request, params httprouter.Params)
MachineCreate creates a new machine
func (*Handler) MachineDelete ¶
func (h *Handler) MachineDelete(w http.ResponseWriter, r *http.Request, params httprouter.Params)
MachineDelete deletes a machine
func (*Handler) MachineInfo ¶
func (h *Handler) MachineInfo(w http.ResponseWriter, r *http.Request, params httprouter.Params)
MachineInfo return info about a machine
func (*Handler) MachineList ¶
func (h *Handler) MachineList(w http.ResponseWriter, r *http.Request, params httprouter.Params)
MachineList lists all machines of a user
func (*Handler) SessionControl ¶
func (h *Handler) SessionControl(w http.ResponseWriter, r *http.Request, params httprouter.Params)
SessionControl exposes the control socket
func (*Handler) SessionCreate ¶
func (h *Handler) SessionCreate(w http.ResponseWriter, r *http.Request, params httprouter.Params)
SessionCreate creates a new exec session
func (*Handler) SessionIO ¶
func (h *Handler) SessionIO(w http.ResponseWriter, r *http.Request, params httprouter.Params)
SessionIO exposes the io socket
type SessionCreateRequest ¶
type SessionCreateRequest struct { Name string `jsonapi:"attr,name"` Width int `jsonapi:"attr,width"` Height int `jsonapi:"attr,height"` }
SessionCreateRequest defines the data structure of a SessionCreate request
type SessionCreateResponse ¶
type SessionCreateResponse struct {
ID string `jsonapi:"primary,sessions"`
}
SessionCreateResponse defines the data structure of a SessionCreate response
Click to show internal directories.
Click to hide internal directories.