Add support for out of capacity error message
This commit is contained in:
@@ -2,10 +2,12 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/play-with-docker/play-with-docker/provisioner"
|
||||
"github.com/play-with-docker/play-with-docker/pwd"
|
||||
"github.com/play-with-docker/play-with-docker/pwd/types"
|
||||
)
|
||||
@@ -25,6 +27,10 @@ func NewInstance(rw http.ResponseWriter, req *http.Request) {
|
||||
if pwd.SessionComplete(err) {
|
||||
rw.WriteHeader(http.StatusConflict)
|
||||
return
|
||||
} else if provisioner.OutOfCapacity(err) {
|
||||
rw.WriteHeader(http.StatusServiceUnavailable)
|
||||
fmt.Fprintln(rw, `{"error": "out_of_capacity"}`)
|
||||
return
|
||||
}
|
||||
log.Println(err)
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user