re-add open access-control headers to feeds
3 files changed, 7 insertions(+), 11 deletions(-)
M domain/content/builder/builder.go → domain/content/builder/builder.go
@@ -35,12 +35,6 @@ Storage storage.Writer `conf:"-"` Repo *vcs.Repository `conf:"-"` } -var feedHeaders = map[string]string{ - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Max-Age": "3600", -} - func joinSourcePath(src string) func(string) string { return func(rel string) string { return filepath.Join(src, rel)@@ -165,7 +159,6 @@ file := &storage.File{ Title: title, LastModified: matchingPosts[0].Date, ContentType: "application/xml", - Headers: feedHeaders, Path: path.Join("/tags", tag, "atom.xml"), FSPath: path.Join("/tags", tag, "atom.xml"), }@@ -199,7 +192,6 @@ file := &storage.File{ Title: config.Title, LastModified: cc.Posts[0].Date, ContentType: "application/xml", - Headers: feedHeaders, Path: "/atom.xml", FSPath: "/atom.xml", }
M domain/web/mux.go → domain/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) } }