diff --git a/outputMeta/packagemetatagoutputter.go b/outputMeta/packagemetatagoutputter.go index 72f361e..5380b48 100644 --- a/outputMeta/packagemetatagoutputter.go +++ b/outputMeta/packagemetatagoutputter.go @@ -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 { diff --git a/web/web.go b/web/web.go index 1498fea..94ba46c 100644 --- a/web/web.go +++ b/web/web.go @@ -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")