Merge pull request #11 from Natureshadow/feature-no-redirect
Do not redirect if no requestOrigin is set
This commit is contained in:
commit
ad8e700e7a
|
@ -300,6 +300,7 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) {
|
|||
contactResponse.Message = "Invalid request, please review your input and try again."
|
||||
}
|
||||
|
||||
if contactRequest.OriginURI != "" {
|
||||
originURL, err := url.Parse(contactRequest.OriginURI)
|
||||
if err != nil {
|
||||
log.Printf("error parsing the origin URL %s (%s)", originURL, err.Error())
|
||||
|
@ -311,10 +312,14 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) {
|
|||
q.Set("message", contactResponse.Message)
|
||||
originURL.RawQuery = q.Encode()
|
||||
|
||||
respRawData, _ := json.Marshal(contactResponse)
|
||||
|
||||
httpResp.Header().Set("Location", originURL.String())
|
||||
httpResp.WriteHeader(http.StatusSeeOther)
|
||||
} else {
|
||||
httpResp.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
respRawData, _ := json.Marshal(contactResponse)
|
||||
|
||||
httpResp.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
httpResp.Write(respRawData)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue