Implement getRequestCookies

Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com>
This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-17 15:35:29 +02:00
parent cfac3fafaa
commit f5d7521a45
2 changed files with 98 additions and 1 deletions
+12
View File
@@ -69,3 +69,15 @@ func getRequestHeaders(w http.ResponseWriter, r *http.Request, h *model.Handler)
w.WriteHeader(http.StatusNotFound)
}
}
// TODO: Add to the note section of the specification the fact that
// Cookie keys are CaseSensitive
func getRequestCookies(w http.ResponseWriter, r *http.Request, h *model.Handler) {
w.Header().Add("Content-Type", "application/octet-stream")
name := mux.Vars(r)["name"]
if cookie, err := h.Request.Cookie(name); err == nil {
_, _ = w.Write([]byte(cookie.Value))
} else {
w.WriteHeader(http.StatusNotFound)
}
}