-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhostelStatus.go
36 lines (27 loc) · 985 Bytes
/
hostelStatus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"encoding/json"
"net/http"
)
// StatusGet .
func StatusGet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
var response = make(map[string]interface{})
response["meta"] = setMeta(statusCodeOk, "", "")
// if getHostelStatus(r.FormValue("hostel_id")) {
// response["meta"] = setMeta(statusCodeOk, "", "")
// } else {
// response["meta"] = setMeta(statusCodeForbidden, "", "")
// }
w.WriteHeader(getHTTPStatusCode(response["meta"].(map[string]string)["status"]))
json.NewEncoder(w).Encode(response)
}
// StatusSet .
func StatusSet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
var response = make(map[string]interface{})
setHostelExpiry(r.FormValue("hostel_id"))
response["meta"] = setMeta(statusCodeOk, "Updated", dialogType)
w.WriteHeader(getHTTPStatusCode(response["meta"].(map[string]string)["status"]))
json.NewEncoder(w).Encode(response)
}