server: add routes to md

This commit is contained in:
2026-06-03 01:17:31 +00:00
parent 92ddff0917
commit 007e61bca1
5 changed files with 172 additions and 0 deletions
+13
View File
@@ -2,6 +2,8 @@ package api
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"strings"
@@ -9,8 +11,11 @@ import (
"git.dubyatp.xyz/dubyatp/scannerbot/server/db"
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
"github.com/go-chi/docgen"
)
var routes = flag.Bool("routes", false, "Generate API route documentation")
func Start() {
ctx := context.Background()
db.InitPostgres(ctx)
@@ -88,5 +93,13 @@ func Start() {
r.Post("/", NewUser)
})
if *routes {
fmt.Println(docgen.MarkdownRoutesDoc(r, docgen.MarkdownOpts{
ProjectPath: "git.dubyatp.xyz/williamp/scannerbot",
Intro: "ScannerBot Server API routes",
}))
return
}
http.ListenAndServe(":3000", r)
}