server: add routes to md
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user