main.go

41 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
package main

import (
	"embed"
	"net/http"

	"congo.gg"
	"congo.gg/pkg/application"
	"congo.gg/web/controllers"
)

//go:embed all:views
var views embed.FS

func main() {
	// AI/SEO: serve framework context for LLM discoverability
	http.HandleFunc("GET /llms.txt", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
		w.Write([]byte(congo.ClaudeContext))
	})
	http.HandleFunc("GET /robots.txt", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
		w.Write([]byte("User-agent: *\nAllow: /\n\nSitemap: https://congo.gg/sitemap.txt\n"))
	})
	http.HandleFunc("GET /sitemap.txt", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
		w.Write([]byte("https://congo.gg/\nhttps://congo.gg/tutorial\nhttps://congo.gg/guide\nhttps://congo.gg/philosophy\nhttps://congo.gg/download\nhttps://congo.gg/source\n"))
	})

	application.Serve(views,
		application.WithValue("theme", "light"),
		application.WithMiddleware(application.NonceMiddleware()),
		application.WithMiddleware(application.SecurityHeaders()),
		application.WithController(controllers.Home()),
		application.WithController(controllers.Source(congo.SourceFS)),
		application.WithController(controllers.MailingList()),
		application.WithController(controllers.Stars()),
		application.WithController(controllers.Downloads()),
		application.WithController(controllers.Git()),
	)
}