~sircmpwn/gmni-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH kineto] Update go-gemini dependency

Details
Message ID
<20210225041620.7896-1-me@adnano.co>
DKIM signature
pass
Download raw message
Patch: +19 -14
---
Version 0.1.17 has first-class support for contexts.

 go.mod  |  2 +-
 go.sum  | 11 +++++++++--
 main.go | 20 +++++++++-----------
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/go.mod b/go.mod
index 623c48d..dd7dcaf 100644
--- a/go.mod
+++ b/go.mod
@@ -3,6 +3,6 @@ module git.sr.ht/~sircmpwn/kineto
go 1.15

require (
	git.sr.ht/~adnano/go-gemini v0.1.13
	git.sr.ht/~adnano/go-gemini v0.1.17
	git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3
)
diff --git a/go.sum b/go.sum
index f37e299..2d2857b 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
git.sr.ht/~adnano/go-gemini v0.1.13 h1:vzKkkVrOzMpfJ1AAeE/PChg0Rw5Zf+9HrnwsgVxXUT4=
git.sr.ht/~adnano/go-gemini v0.1.13/go.mod h1:If1VxEWcZDrRt5FeAFnGTcM2Ud1E3BXs3VJ5rnZWKq0=
git.sr.ht/~adnano/go-gemini v0.1.17 h1:CJ3tDaqAJQbOdVXmiPC/iXHt4lF/CRu2nxPNOPjHUBk=
git.sr.ht/~adnano/go-gemini v0.1.17/go.mod h1:hQ75Y0i5jSFL+FQ7AzWVAYr5LQsaFC7v3ZviNyj46dY=
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3 h1:4wDp4BKF7NQqoh73VXpZsB/t1OEhDpz/zEpmdQfbjDk=
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
@@ -9,3 +9,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/main.go b/main.go
index fd02310..ba36a6d 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main

import (
	"context"
	"fmt"
	"html/template"
	"io"
@@ -383,15 +384,12 @@ type GemtextHeading struct {

func proxyGemini(req gemini.Request, external bool, root *url.URL,
	w http.ResponseWriter, r *http.Request, css string) {
	client := gemini.Client{
		Timeout: 30 * time.Second,
	}

	if h := (url.URL{Host: req.Host}); h.Port() == "" {
		req.Host += ":1965"
	}
	ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second)
	defer cancel()

	resp, err := client.Do(&req)
	client := gemini.Client{}
	resp, err := client.Do(ctx, &req)
	if err != nil {
		w.WriteHeader(http.StatusBadGateway)
		fmt.Fprintf(w, "Gateway error: %v", err)
@@ -480,7 +478,7 @@ func proxyGemini(req gemini.Request, external bool, root *url.URL,
	lang := params["lang"]

	w.Header().Add("Content-Type", "text/html")
	ctx := &GemtextContext{
	gemctx := &GemtextContext{
		CSS:      css,
		External: external,
		Resp:     resp,
@@ -492,16 +490,16 @@ func proxyGemini(req gemini.Request, external bool, root *url.URL,

	var title bool
	gemini.ParseLines(resp.Body, func(line gemini.Line) {
		ctx.Lines = append(ctx.Lines, line)
		gemctx.Lines = append(gemctx.Lines, line)
		if !title {
			if h, ok := line.(gemini.LineHeading1); ok {
				ctx.Title = string(h)
				gemctx.Title = string(h)
				title = true
			}
		}
	})

	err = gemtextPage.Execute(w, ctx)
	err = gemtextPage.Execute(w, gemctx)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		fmt.Fprintf(w, "%v", err)
-- 
2.30.1
Reply to thread Export thread (mbox)