Commit 899547a6 authored by CodeFever888's avatar CodeFever888
Browse files

'sever'

parent 44ba2b60
......@@ -57,6 +57,8 @@ func init() {
func enableCors(w http.ResponseWriter) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
}
func getHandler(w http.ResponseWriter, r *http.Request) {
......@@ -98,6 +100,8 @@ func getHandler(w http.ResponseWriter, r *http.Request) {
}
func addHandler(w http.ResponseWriter, r *http.Request) {
enableCors(w)
w.Header().Set("Content-Type", "application/json")
var comment Comment
json.NewDecoder(r.Body).Decode(&comment)
......@@ -118,6 +122,8 @@ func addHandler(w http.ResponseWriter, r *http.Request) {
}
func deleteHandler(w http.ResponseWriter, r *http.Request) {
enableCors(w)
w.Header().Set("Content-Type", "application/json")
id := r.URL.Query().Get("id")
idInt, err := strconv.Atoi(id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment