summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/cowsay/main.go3
-rw-r--r--examples/fetch/main.go6
-rw-r--r--examples/fileserver/main.go3
-rw-r--r--examples/inspectls/main.go3
4 files changed, 10 insertions, 5 deletions
diff --git a/examples/cowsay/main.go b/examples/cowsay/main.go
index be81f50..fc5e89f 100644
--- a/examples/cowsay/main.go
+++ b/examples/cowsay/main.go
@@ -8,6 +8,7 @@ import (
"os"
"os/exec"
+ "tildegit.org/tjp/gus"
guslog "tildegit.org/tjp/gus/contrib/log"
"tildegit.org/tjp/gus/gemini"
)
@@ -33,7 +34,7 @@ func main() {
server.Serve()
}
-func cowsayHandler(ctx context.Context, req *gemini.Request) *gemini.Response {
+func cowsayHandler(ctx context.Context, req *gus.Request) *gus.Response {
// prompt for a query if there is none already
if req.RawQuery == "" {
return gemini.Input("enter a phrase")
diff --git a/examples/fetch/main.go b/examples/fetch/main.go
index adfece4..109a042 100644
--- a/examples/fetch/main.go
+++ b/examples/fetch/main.go
@@ -8,6 +8,7 @@ import (
"os"
"strings"
+ "tildegit.org/tjp/gus"
"tildegit.org/tjp/gus/gemini"
)
@@ -29,20 +30,21 @@ func main() {
}
// parse the URL and build the request
- request := &gemini.Request{URL: buildURL()}
+ request := &gus.Request{URL: buildURL()}
// fetch the response
response, err := client.RoundTrip(request)
if err != nil {
log.Fatal(err)
}
+ defer response.Close()
if response.Status != gemini.StatusSuccess {
log.Fatalf("%d %s\n", response.Status, response.Meta)
}
//io.Copy(os.Stdout, response)
- buf, err := io.ReadAll(response)
+ buf, err := io.ReadAll(gemini.NewResponseReader(response))
fmt.Printf("response: %s\n", buf)
}
diff --git a/examples/fileserver/main.go b/examples/fileserver/main.go
index b38ae76..35c8708 100644
--- a/examples/fileserver/main.go
+++ b/examples/fileserver/main.go
@@ -5,6 +5,7 @@ import (
"log"
"os"
+ "tildegit.org/tjp/gus"
"tildegit.org/tjp/gus/contrib/fs"
guslog "tildegit.org/tjp/gus/contrib/log"
"tildegit.org/tjp/gus/gemini"
@@ -23,7 +24,7 @@ func main() {
// build the request handler
fileSystem := os.DirFS(".")
// Fallthrough tries each handler in succession until it gets something other than "51 Not Found"
- handler := gemini.FallthroughHandler(
+ handler := gus.FallthroughHandler(
// first see if they're fetching a directory and we have <dir>/index.gmi
fs.DirectoryDefault(fileSystem, "index.gmi"),
// next (still if they requested a directory) build a directory listing response
diff --git a/examples/inspectls/main.go b/examples/inspectls/main.go
index d690af1..65c5229 100644
--- a/examples/inspectls/main.go
+++ b/examples/inspectls/main.go
@@ -12,6 +12,7 @@ import (
"os"
"strings"
+ "tildegit.org/tjp/gus"
guslog "tildegit.org/tjp/gus/contrib/log"
"tildegit.org/tjp/gus/gemini"
)
@@ -51,7 +52,7 @@ func envConfig() (string, string) {
return certfile, keyfile
}
-func inspectHandler(ctx context.Context, req *gemini.Request) *gemini.Response {
+func inspectHandler(ctx context.Context, req *gus.Request) *gus.Response {
// build and return a ```-wrapped description of the connection TLS state
body := "```\n" + displayTLSState(req.TLSState) + "\n```"
return gemini.Success("text/gemini", bytes.NewBufferString(body))