~poldi1405/gomod-recter

133c8cb2d7fe108dbf35e2d98daed86c7c9afd76 — Moritz Poldrack 2 years ago 67fd0cd
now returning 404 when go get to unknown project
1 files changed, 6 insertions(+), 0 deletions(-)

M internal/handler/handler.go
M internal/handler/handler.go => internal/handler/handler.go +6 -0
@@ 39,6 39,12 @@ func FasthttpHandler(ctx *fasthttp.RequestCtx) {
		projectHandler(ctx, string(path[1]), remainingPath)
	default:
		glog.Warnf("project '%s' not found in config", path[1])
		if ctx.URI().QueryArgs().GetBool("go-get") {
			glog.Debug("detected go-get, sending 404")
			ctx.SetStatusCode(fasthttp.StatusNotFound)
			ctx.WriteString(`<html><head><title>Project not found</title></head><body><h1>404 - Not found!</h1><p>This Project does not exist.</p></body></html>`)
			return
		}
		ctx.Redirect("/", fasthttp.StatusSeeOther)
	}
}