Fix the package name output when username is specified, Fixes #1 .
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Captain ALM 2022-07-12 12:01:53 +01:00
parent 61864ac508
commit 8759f57f1c
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
2 changed files with 15 additions and 5 deletions

View File

@ -41,11 +41,7 @@ func (pkgMTO *PackageMetaTagOutputter) getPrefix(pathIn string) string {
if pkgMTO.BasePath == "" {
return "_"
}
if pkgMTO.Username == "" {
return path.Join(pkgMTO.BasePath, pathIn)
} else {
return path.Join(pkgMTO.BasePath, pkgMTO.Username, pathIn)
}
return path.Join(pkgMTO.BasePath, pathIn)
}
func (pkgMTO *PackageMetaTagOutputter) getHomeURL(pathIn string) string {

View File

@ -26,6 +26,7 @@ func New(yaml conf.ConfigYaml) (*http.Server, map[string]*PageHandler) {
}
}
}
router.PathPrefix("/").HandlerFunc(domainNotAllowed)
if yaml.Listen.Identify {
router.Use(headerMiddleware)
}
@ -53,6 +54,19 @@ func runBackgroundHttp(s *http.Server) {
}
}
func domainNotAllowed(rw http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodGet || req.Method == http.MethodHead {
writeResponseHeaderCanWriteBody(req.Method, rw, http.StatusNotFound, "Domain Not Allowed")
} else {
rw.Header().Set("Allow", http.MethodOptions+", "+http.MethodGet+", "+http.MethodHead)
if req.Method == http.MethodOptions {
writeResponseHeaderCanWriteBody(req.Method, rw, http.StatusOK, "")
} else {
writeResponseHeaderCanWriteBody(req.Method, rw, http.StatusMethodNotAllowed, "")
}
}
}
func headerMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "Clerie Gilbert")