chore: initial setup

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-06-24 11:50:06 -03:00
commit 2686a045fd
23 changed files with 732 additions and 0 deletions

27
api/robots.go Normal file
View File

@@ -0,0 +1,27 @@
package api
import (
"io"
"net/http"
"extrovert/internals"
)
func RobotsTxt(w http.ResponseWriter, r *http.Request) {
error := internals.HttpErrorHelper(w)
aiList, err := http.Get("https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/main/robots.txt")
if error("Error trying to fetch ai block list", err, http.StatusInternalServerError) {
return
}
bytes, err := io.ReadAll(aiList.Body)
if error("Error trying to read ai block list", err, http.StatusInternalServerError) {
return
}
w.Write(bytes)
w.Header().Add("Cache-Control", "max-age=604800, stale-while-revalidate=86400, stale-if-error=86400")
w.Header().Add("CDN-Cache-Control", "max-age=604800")
w.Header().Add("Content-Type", "text/plain")
}