Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Set correct content type and send once#1965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
matt0x6F merged 4 commits intogomods:mainfrommatt0x6F:fix-content-types
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletioncmd/proxy/actions/app.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,6 @@ func App(logger *log.Logger, conf *config.Config) (http.Handler, error) {
SSLRedirect: conf.ForceSSL,
SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"},
}).Handler,
mw.ContentType,
)

var subRouter *mux.Router
Expand Down
1 change: 1 addition & 0 deletionscmd/proxy/actions/catalog.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@ func catalogHandler(s storage.Backend) http.HandlerFunc {
const op errors.Op = "actions.CatalogHandler"
cs, isCataloger := s.(storage.Cataloger)
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if !isCataloger {
w.WriteHeader(errors.KindNotImplemented)
return
Expand Down
1 change: 1 addition & 0 deletionscmd/proxy/actions/health.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,5 +5,6 @@ import (
)

func healthHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
}
2 changes: 1 addition & 1 deletioncmd/proxy/actions/home.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func proxyHomeHandler(c *config.Config) http.HandlerFunc {
w.WriteHeader(http.StatusInternalServerError)
}

w.Header().Add("Content-Type", "text/html")
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusOK)

err = tmp.ExecuteTemplate(w, "home", templateData)
Expand Down
2 changes: 2 additions & 0 deletionscmd/proxy/actions/index.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,8 @@ func indexHandler(index index.Indexer) http.HandlerFunc {
http.Error(w, err.Error(), errors.Kind(err))
return
}

w.Header().Set("Content-Type", "application/json; charset=utf-8")
enc := json.NewEncoder(w)
for _, meta := range list {
if err = enc.Encode(meta); err != nil {
Expand Down
1 change: 1 addition & 0 deletionscmd/proxy/actions/readiness.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
func getReadinessHandler(s storage.Backend) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if _, err := s.List(r.Context(), "github.com/gomods/athens"); err != nil {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusInternalServerError)
}
}
Expand Down
1 change: 1 addition & 0 deletionscmd/proxy/actions/robots.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
// robotsHandler implements GET baseURL/robots.txt.
func robotsHandler(c *config.Config) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
http.ServeFile(w, r, c.RobotsFile)
}
}
2 changes: 2 additions & 0 deletionscmd/proxy/actions/version.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,4 +9,6 @@ import (

func versionHandler(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode(build.Data())
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
}
1 change: 1 addition & 0 deletionspkg/download/latest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ const PathLatest = "/{module:.+}/@latest"
func LatestHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler {
const op errors.Op = "download.LatestHandler"
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
mod, err := paths.GetModule(r)
if err != nil {
lggr.SystemErr(errors.E(op, err))
Expand Down
1 change: 1 addition & 0 deletionspkg/download/list.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ const PathList = "/{module:.+}/@v/list"
func ListHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler {
const op errors.Op = "download.ListHandler"
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
mod, err := paths.GetModule(r)
if err != nil {
lggr.SystemErr(errors.E(op, err))
Expand Down
1 change: 1 addition & 0 deletionspkg/download/version_info.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ const PathVersionInfo = "/{module:.+}/@v/{version}.info"
func InfoHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler {
const op errors.Op = "download.InfoHandler"
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
mod, ver, err := getModuleParams(r, op)
if err != nil {
lggr.SystemErr(err)
Expand Down
1 change: 1 addition & 0 deletionspkg/download/version_module.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ const PathVersionModule = "/{module:.+}/@v/{version}.mod"
func ModuleHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler {
const op errors.Op = "download.VersionModuleHandler"
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
mod, ver, err := getModuleParams(r, op)
if err != nil {
err = errors.E(op, errors.M(mod), errors.V(ver), err)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp