fix password but no username, update modules

This commit is contained in:
Your Name 2023-04-21 11:34:20 -05:00
parent 0fd317fd56
commit c9a0ba672e
3 changed files with 14 additions and 8 deletions

2
go.mod
View File

@ -3,6 +3,6 @@ module git.teamworkapps.com/shortcut/httphere
go 1.17 go 1.17
require ( require (
git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20181107163431-49cae39a0eb7 git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20230421162957-948ff8787756
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
) )

2
go.sum
View File

@ -1,4 +1,6 @@
git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20181107163431-49cae39a0eb7 h1:wl0faTtewN9Y0nTZpRY2mcaIhVkaR1l8k920U0rDIk0= git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20181107163431-49cae39a0eb7 h1:wl0faTtewN9Y0nTZpRY2mcaIhVkaR1l8k920U0rDIk0=
git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20181107163431-49cae39a0eb7/go.mod h1:4t5y+BFcMRTe6GkAX72YXcjrKbGkOVM7CkJMRHNZYiQ= git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20181107163431-49cae39a0eb7/go.mod h1:4t5y+BFcMRTe6GkAX72YXcjrKbGkOVM7CkJMRHNZYiQ=
git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20230421162957-948ff8787756 h1:ViHTT1GI1JlsLrUsivl4tvg6DySn35d1C3bzXeLa8uY=
git.teamworkapps.com/shortcut/enhancedfileserver v0.0.0-20230421162957-948ff8787756/go.mod h1:Px7gD0CL+z9WBsvFPtCuDpVEJNStJXrbFRD3q7aJwYk=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=

12
main.go
View File

@ -35,18 +35,22 @@ func init() {
func main() { func main() {
r := mux.NewRouter() r := mux.NewRouter()
if c.username != "" && c.password == "" { if c.username == "" && c.password != "" {
c.username = "admin" c.username = "admin"
} }
if c.username != "" && c.password != "" {
r.Use(basicAuth)
}
if c.log { if c.log {
r.Use(queryLog) r.Use(queryLog)
} }
if c.username != "" && c.password != "" {
r.Use(basicAuth)
}
if c.nocache { if c.nocache {
r.Use(noCache) r.Use(noCache)
} }
if c.noindex { if c.noindex {
r.PathPrefix("/").Handler(http.StripPrefix("/", enhancedfileserver.FileServerNoIndex(http.Dir("./")))) r.PathPrefix("/").Handler(http.StripPrefix("/", enhancedfileserver.FileServerNoIndex(http.Dir("./"))))
} else { } else {