all repos — homestead @ a0bb10d9dea0d560a0ca4ccc7d9d4bf3848242e7

Code for my website

re-add open access-control headers to feeds

Alan Pearce
commit

a0bb10d9dea0d560a0ca4ccc7d9d4bf3848242e7

parent

2edd98046639d440b7a5a191c1bec2d338f1c7cf

1 file changed, 7 insertions(+), 2 deletions(-)

changed files
M domain/web/mux.godomain/web/mux.go
@@ -19,6 +19,11 @@ var (
ErrReadingFile = ihttp.NewError("Error reading file", http.StatusInternalServerError) ErrNotFound = ihttp.NewError("File not found", http.StatusNotFound) ErrRenderFailure = ihttp.NewError("Error rendering template", http.StatusInternalServerError) + feedHeaders = map[string]string{ + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Max-Age": "3600", + } ) func (website *Website) ErrorHandler(err ihttp.Error, w http.ResponseWriter, r *http.Request) {
@@ -64,8 +69,8 @@ if enc != "" {
w.Header().Add("Content-Encoding", enc) } w.Header().Add("Content-Type", file.ContentType) - if file.Headers != nil { - for k, v := range file.Headers { + if file.ContentType == "application/xml" { + for k, v := range feedHeaders { w.Header().Add(k, v) } }