From 35bf4d16c38e1beb9af644bc6fe3a894f7a6d5f9 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Wed, 1 Jul 2020 16:05:39 +0200 Subject: [PATCH] Handle all requests which don't involve the filesystem before all which do. --- handler.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/handler.go b/handler.go index ab10646..2fad0ef 100644 --- a/handler.go +++ b/handler.go @@ -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) {