remove those many annoying fmt.Println() calls on every handler.

This commit is contained in:
fiatjaf
2024-06-12 15:42:56 -03:00
parent eec788101f
commit b19f066a9d
8 changed files with 1 additions and 20 deletions

View File

@@ -43,7 +43,6 @@ func renderOEmbed(w http.ResponseWriter, r *http.Request) {
return
}
code := strings.Split(targetURL.Path, "/")[1]
fmt.Println(targetURL.Path, "&^", r.Header.Get("user-agent"))
if !strings.HasPrefix(code, "nevent1") {
http.Error(w, "oembed is only supported for nevent1 codes, not '"+code+"'", 400)

View File

@@ -1,15 +1,12 @@
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
)
func proxy(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
w.Header().Set("Cache-Control", "max-age=604800")
src := r.URL.Query().Get("src")

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"math/rand"
"net/http"
"strconv"
@@ -17,8 +16,6 @@ const (
)
func renderArchive(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, "@.", r.Header.Get("user-agent"))
lastIndex := strings.LastIndex(r.URL.Path, "/")
page := 1
if lastIndex != -1 {

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"html"
"html/template"
"net/http"
@@ -16,8 +15,6 @@ func renderEmbedjs(w http.ResponseWriter, r *http.Request) {
}
func renderEmbedded(w http.ResponseWriter, r *http.Request, code string) {
fmt.Println(r.URL.Path, "@.", r.Header.Get("user-agent"))
data, err := grabData(r.Context(), code, false)
if err != nil {
w.Header().Set("Cache-Control", "max-age=60")

View File

@@ -109,7 +109,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
}
// from here onwards we know we're rendering an event
fmt.Println(r.URL.Path, "#/", r.Header.Get("user-agent"))
//
// gather page style from user-agent
style := getPreviewStyle(r)
@@ -125,7 +125,6 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
for _, tag := range data.event.Tags {
if tag[0] == "subject" || tag[0] == "title" {
subject = tag[1]
}
if tag[0] == "summary" {
summary = tag[1]

View File

@@ -36,8 +36,6 @@ var fonts embed.FS
var multiNewlineRe = regexp.MustCompile(`\n\n+`)
func renderImage(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
code := r.URL.Path[1+len("njump/image/"):]
if code == "" {
fmt.Fprintf(w, "call /njump/image/<nip19 code>")

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"html"
"html/template"
"net/http"
@@ -9,8 +8,6 @@ import (
)
func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
fmt.Println(r.URL.Path, "@.", r.Header.Get("user-agent"))
isSitemap := false
if strings.HasSuffix(code, ".xml") {
code = code[:len(code)-4]

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"net/http"
"strings"
"time"
@@ -10,8 +9,6 @@ import (
)
func renderRelayPage(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, "@.", r.Header.Get("user-agent"))
hostname := r.URL.Path[3:]
if strings.HasPrefix(hostname, "wss:/") || strings.HasPrefix(hostname, "ws:/") {