this repo has no description
1package server 2 3import ( 4 "database/sql" 5 "net/http" 6 7 "github.com/bluesky-social/indigo/atproto/auth/oauth" 8 "github.com/go-chi/chi/v5" 9 "github.com/gorilla/sessions" 10 "tangled.org/core/knot2/config" 11 "tangled.org/core/knot2/server/handler" 12 "tangled.org/core/knot2/server/middleware" 13) 14 15func Routes( 16 cfg *config.Config, 17 d *sql.DB, 18 clientApp *oauth.ClientApp, 19) http.Handler { 20 r := chi.NewRouter() 21 22 r.Use(middleware.CORS) 23 r.Use(middleware.RequestLogger) 24 25 r.Get("/", func(w http.ResponseWriter, r *http.Request) { 26 w.Write([]byte("This is a knot server. More info at https://tangled.sh")) 27 }) 28 29 jar := sessions.NewCookieStore([]byte(cfg.OAuth.CookieSecret)) 30 31 r.Get("/register", handler.Register(jar)) 32 r.Post("/register", handler.RegisterPost(cfg, d, clientApp, jar)) 33 r.Post("/oauth/login", handler.OauthLoginPost(clientApp)) 34 r.Get("/oauth/client-metadata.json", handler.OauthClientMetadata(cfg, clientApp)) 35 r.Get("/oauth/jwks.json", handler.OauthJwks(clientApp)) 36 r.Get("/oauth/callback", handler.OauthCallback(clientApp, jar)) 37 38 r.Route("/{did}/{name}", func(r chi.Router) { 39 r.Get("/info/refs", handler.InfoRefs()) 40 r.Post("/git-upload-pack", handler.GitUploadPack()) 41 r.Post("/git-receive-pack", handler.GitReceivePack()) 42 }) 43 44 r.Get("/events", handler.Events()) 45 46 // r.Route("/xrpc", func(r chi.Router) { 47 // r.Post("/"+tangled.GitKeepRefNSID, handler.GitKeepRef()) 48 // }) 49 50 return r 51}