1
0
Fork 0

Handle all requests which don't involve the filesystem before all which do.

This commit is contained in:
Solderpunk 2020-07-01 16:05:39 +02:00
parent 9bce54882a
commit 35bf4d16c3

View file

@ -90,6 +90,15 @@ func handleGeminiRequest(conn net.Conn, config Config, accessLogEntries chan Log
return
}
// Check whether this URL is mapped to an SCGI app
for scgi_url, scgi_socket := range config.SCGIPaths {
matched, err := regexp.Match(scgi_url, []byte(URL.Path))
if matched && err == nil {
handleSCGI(scgi_socket, config, URL, &log, conn)
return
}
}
// Check whether this URL is in a configured CGI path
var cgiPaths []string
for _, cgiPath := range config.CGIPaths {
@ -109,15 +118,6 @@ func handleGeminiRequest(conn net.Conn, config Config, accessLogEntries chan Log
}
}
// Check whether this URL is mapped to an SCGI app
for scgi_url, scgi_socket := range config.SCGIPaths {
matched, err := regexp.Match(scgi_url, []byte(URL.Path))
if matched && err == nil {
handleSCGI(scgi_socket, config, URL, &log, conn)
return
}
}
// Fail if file does not exist or perms aren't right
info, err := os.Stat(path)
if os.IsNotExist(err) || os.IsPermission(err) {