fix headers
s-ol
1 year, 2 months ago
0 | 0 |
{
|
1 | |
"RefererPattern": "^https://localhost($|/)",
|
2 | |
"RedirectTemplate": "https://localhost/form?id={{.Id}}&key={{.Key}}"
|
|
1 |
"RefererPattern": "^http://localhost:8000/",
|
|
2 |
"RedirectTemplate": "http://localhost:8000/form?id={{.Id}}&key={{.Key}}"
|
3 | 3 |
}
|
8 | 8 |
"description": "The person's first name.",
|
9 | 9 |
"format": "email"
|
10 | 10 |
},
|
11 | |
"ages": {
|
|
11 |
"contents": {
|
12 | 12 |
"type": "array",
|
13 | 13 |
"items": {
|
14 | |
"type": "integer",
|
15 | |
"minimum": 0
|
|
14 |
"type": "string",
|
|
15 |
"enum": [
|
|
16 |
"keycaps",
|
|
17 |
"0xC.pad",
|
|
18 |
"0x33.board",
|
|
19 |
"midi",
|
|
20 |
"hid"
|
|
21 |
]
|
16 | 22 |
}
|
17 | 23 |
},
|
18 | |
"firstName": {
|
|
24 |
"frequency": {
|
19 | 25 |
"type": "string",
|
20 | |
"description": "The person's first name."
|
21 | |
},
|
22 | |
"lastName": {
|
23 | |
"type": "string",
|
24 | |
"description": "The person's last name."
|
|
26 |
"enum": [
|
|
27 |
"release",
|
|
28 |
"rare"
|
|
29 |
]
|
25 | 30 |
}
|
26 | 31 |
},
|
27 | 32 |
"additionalProperties": false,
|
28 | |
"minProperties": 1
|
|
33 |
"minProperties": 2
|
29 | 34 |
}
|
111 | 111 |
}
|
112 | 112 |
|
113 | 113 |
func (h *SiteHandler) collectData(r *http.Request) (map[string]interface{}, error) {
|
114 | |
err := r.ParseMultipartForm(0)
|
|
114 |
content_type := r.Header.Get("Content-Type")
|
|
115 |
var err error
|
|
116 |
if content_type == "application/x-www-form-urlencoded" {
|
|
117 |
err = r.ParseForm()
|
|
118 |
} else if content_type == "multipart/form-data" {
|
|
119 |
err = r.ParseMultipartForm(1 * 1024 * 1024)
|
|
120 |
}
|
115 | 121 |
if err != nil {
|
116 | 122 |
return nil, &HTTPError{http.StatusBadRequest, err}
|
117 | 123 |
}
|
|
189 | 195 |
|
190 | 196 |
w.Header().Set("Content-Type", "application/json")
|
191 | 197 |
w.Header().Set("Location", redirect_buf.String())
|
192 | |
w.WriteHeader(http.StatusCreated)
|
|
198 |
w.WriteHeader(http.StatusSeeOther)
|
193 | 199 |
w.Write(raw_data)
|
194 | 200 |
return nil
|
195 | 201 |
}
|
|
252 | 258 |
case *HTTPError:
|
253 | 259 |
code = e.code
|
254 | 260 |
if e.root != nil {
|
255 | |
log.Printf("Error: %#v", err)
|
|
261 |
log.Printf("Error %s: ", err.Error(), e.root)
|
256 | 262 |
}
|
257 | 263 |
default:
|
258 | 264 |
code = http.StatusInternalServerError
|
259 | |
log.Printf("Error: %#v", err)
|
|
265 |
log.Printf("Error: ", err)
|
260 | 266 |
}
|
261 | 267 |
|
262 | 268 |
http.Error(w, http.StatusText(code), code)
|