Fix the package name output when username is specified, Fixes #1 .
This commit is contained in:
parent
61864ac508
commit
8759f57f1c
@ -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 {
|
||||
|
14
web/web.go
14
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")
|
||||
|
Loading…
Reference in New Issue
Block a user