feat: Auto-detect text browsers and serve plain text CV

- Detect curl, wget, lynx, w3m, links, elinks, browsh, carbonyl
- Check User-Agent and Accept: text/plain header
- Redirect to /text endpoint automatically
- Document in SEO guide and modern techniques
This commit is contained in:
juanatsap
2025-11-30 14:28:51 +00:00
parent 768fd3ba72
commit 19951b6f42
4 changed files with 130 additions and 0 deletions
+36
View File
@@ -10,6 +10,42 @@ import (
"text/template"
)
// Text-based browsers and CLI tools that should get plain text
var textBrowsers = []string{
"curl",
"wget",
"httpie",
"lynx",
"w3m",
"links",
"elinks",
"browsh",
"carbonyl",
"netrik",
"retawq",
"surfraw",
}
// isTextBrowser detects if the request comes from a text-based browser or CLI tool
func isTextBrowser(r *http.Request) bool {
ua := strings.ToLower(r.Header.Get("User-Agent"))
// Check for known text browsers
for _, browser := range textBrowsers {
if strings.Contains(ua, browser) {
return true
}
}
// Check Accept header - if client prefers text/plain
accept := r.Header.Get("Accept")
if strings.HasPrefix(accept, "text/plain") {
return true
}
return false
}
// ==============================================================================
// PLAIN TEXT HANDLER
// Renders CV as clean plain text for terminal/AI consumption