Closed Salty2021 closed 3 years ago
The following method of serving static file
g.Static("/test.txt", "content/test.txt")
does not seem to work.
Server running on localhost. When client requests gemini://localhost/test.txt, the server shall return the content of the text file located at content/test.txt. The directory structure used is as follows:
gemini://localhost/test.txt
content/test.txt
--$GOPATH (dir) |--src (dir) |--gig_server (dir) |--content (dir) | |--test.txt | |--imgs (dir) | |--tuxedo_cat.jpg |--main.go |--go.mod |--gig_server (executable) |--my.crt |--my.key
The server returns "not found", and logs the following
time="2021-06-18T06:09:03+00:00" path=/test.txt status=51 duration=0.06 error=Not Found
As described above.
content of main.go:
package main import "github.com/pitr/gig" func main() { g := gig.Default() g.Static("/test.txt", "content/test.txt") g.Run("my.crt", "my.key") }
content of test.txt:
Come find me!
go version go1.16.5 darwin/amd64. gig version 0.9.8
When the "static file" designated is a directory, it works fine. e.g.,
g.Static("/imgs", "content/imgs")
works when client requests gemini://localhost/imgs/tuxedo_cat.jpg.
gemini://localhost/imgs/tuxedo_cat.jpg
I clarified Static section in README. To serve single files, you need to use g.File instead. Static("/test.txt",...) registers /test.txt/*.
g.File
Static("/test.txt",...)
/test.txt/*
Issue Description
The following method of serving static file
does not seem to work.
Checklist
Expected behaviour
Server running on localhost. When client requests
gemini://localhost/test.txt
, the server shall return the content of the text file located atcontent/test.txt
. The directory structure used is as follows:Actual behaviour
The server returns "not found", and logs the following
Steps to reproduce
As described above.
Working code to debug
content of main.go:
content of test.txt:
Version/commit
go version go1.16.5 darwin/amd64. gig version 0.9.8
Note:
When the "static file" designated is a directory, it works fine. e.g.,
works when client requests
gemini://localhost/imgs/tuxedo_cat.jpg
.