~gsthnz/satellite

2373fdfce3746bc3bf25c142ed4d7c5a1e2741a6 — Pedro Lucas Porcellis 3 years ago 8d66355
When dealing with directories, we should try to search for a index.gmi files on it.
1 files changed, 11 insertions(+), 1 deletions(-)

M gemini.go
M gemini.go => gemini.go +11 -1
@@ 50,12 50,22 @@ func handleRequest(c net.Conn, di int, parsedURL *url.URL) {
func serve(c net.Conn, di int, filepath string) {
	fullPath := path.Join(config.Domain[di].Root, filepath)

	_, err := os.Stat(fullPath)
	pathInfo, err := os.Stat(fullPath)
	if err != nil {
		sendError(c, NotFound, "Not found")
		return
	}

	if pathInfo.IsDir() {
		subDirIndex := path.Join(fullPath, IndexFile)
		if _, err := os.Stat(subDirIndex); os.IsNotExist(err) {
			sendError(c, NotFound, "Not found")
			return
		}

		fullPath = subDirIndex
	}

	mimeType := getMimeType(fullPath)

	if mimeType == "" {