format
This commit is contained in:
parent
8788eea4f0
commit
645f40f0c6
@ -44,7 +44,7 @@ func createExerciceFile(theme fic.Theme, exercice fic.Exercice, args []string, b
|
|||||||
return exercice.ImportFile(pathname, uf.URI)
|
return exercice.ImportFile(pathname, uf.URI)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloudFile(pathname string, dest string) (error) {
|
func getCloudFile(pathname string, dest string) error {
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
if req, err := http.NewRequest("GET", CloudDAVBase+pathname, nil); err != nil {
|
if req, err := http.NewRequest("GET", CloudDAVBase+pathname, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -58,7 +58,7 @@ func getCloudFile(pathname string, dest string) (error) {
|
|||||||
if fd, err := os.Create(dest); err != nil {
|
if fd, err := os.Create(dest); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer fd.Close();
|
defer fd.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return errors.New(resp.Status)
|
return errors.New(resp.Status)
|
||||||
|
@ -20,7 +20,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
||||||
// Check request type and size
|
// Check request type and size
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
|
||||||
@ -30,7 +29,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extract URL arguments
|
// Extract URL arguments
|
||||||
var sURL = strings.Split(r.URL.Path, "/")
|
var sURL = strings.Split(r.URL.Path, "/")
|
||||||
|
|
||||||
@ -61,14 +59,12 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Previous submission not treated
|
// Previous submission not treated
|
||||||
if _, err := os.Stat(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); !os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); !os.IsNotExist(err) {
|
||||||
http.Error(w, "{\"errmsg\":\"Du calme ! une tentative est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
|
http.Error(w, "{\"errmsg\":\"Du calme ! une tentative est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read request body
|
// Read request body
|
||||||
var body []byte
|
var body []byte
|
||||||
if r.ContentLength > 0 {
|
if r.ContentLength > 0 {
|
||||||
@ -84,7 +80,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Store content in file
|
// Store content in file
|
||||||
if file, err := os.Create(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); err != nil {
|
if file, err := os.Create(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); err != nil {
|
||||||
log.Println("Unable to open exercice file:", err)
|
log.Println("Unable to open exercice file:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user