From c4520f2c84c0d4555bdb02f4ec7b2d1a8bdefca2 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 23 Jan 2023 16:02:35 +0100 Subject: Automatically bridge gemini links to a gateway on http site --- src/http/http.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/http/http.go') diff --git a/src/http/http.go b/src/http/http.go index da39374..98cdde3 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -56,12 +56,17 @@ type Params struct { // AuthRatelimit indicates how much time must pass between subsequent auth // attempts. AuthRatelimit time.Duration + + // GeminiGatewayURL will be used to translate links for `gemini://` into + // `http(s)://`. See gmi.GemtextToMarkdown. + GeminiGatewayURL *url.URL } // SetupCfg implement the cfg.Cfger interface. func (p *Params) SetupCfg(cfg *cfg.Cfg) { publicURLStr := cfg.String("http-public-url", "http://localhost:4000", "URL this service is accessible at") + geminiGatewayURLStr := cfg.String("http-gemini-gateway-url", "", "Optional URL to prefix to all gemini:// links, to make them accessible over https") cfg.StringVar(&p.ListenProto, "http-listen-proto", "tcp", "Protocol to listen for HTTP requests with") cfg.StringVar(&p.ListenAddr, "http-listen-addr", ":4000", "Address/unix socket path to listen for HTTP requests on") @@ -87,6 +92,12 @@ func (p *Params) SetupCfg(cfg *cfg.Cfg) { return fmt.Errorf("parsing -http-public-url: %w", err) } + if *geminiGatewayURLStr != "" { + if p.GeminiGatewayURL, err = url.Parse(*geminiGatewayURLStr); err != nil { + return fmt.Errorf("parsing -http-gemini-gateway-url: %w", err) + } + } + return nil }) } -- cgit v1.2.3