func NewApp(ctx context.Context) http.Handler { return &application{ ctx: ctx, rt: web.NewRouter(web.Routes{ {"GET", `/`, handleListTopics}, {"GET", `/t`, handleListTopics}, {"GET", `/t/new`, handleCreateTopic}, {"POST", `/t/new`, handleCreateTopic}, {"GET", `/t/{topic-id}`, handleTopicDetails}, {"POST", `/t/{topic-id}/comment`, handleCreateComment}, {"GET", `/login`, auth.LoginHandler("google")}, {"GET", `/login/success`, auth.HandleLoginCallback}, {web.AnyMethod, `.*`, handle404}, }), } }
"golang.org/x/net/context" "golang.org/x/oauth2" oauth2gh "golang.org/x/oauth2/github" "github.com/husio/apps/paste/notes" "github.com/husio/x/auth" "github.com/husio/x/cache" "github.com/husio/x/envconf" "github.com/husio/x/storage/pg" "github.com/husio/x/tmpl" "github.com/husio/x/web" ) var router = web.NewRouter("", web.Routes{ web.GET("/login", "login", auth.LoginHandler("github")), web.GET("/login/success", "", auth.HandleLoginCallback), web.GET("/n/{note-id}", "note-details", notes.HandleDisplayNote), web.GET(`/static/.*`, "", handleStaticDir), }) var statics http.Handler func handleStaticDir(ctx context.Context, w http.ResponseWriter, r *http.Request) { statics.ServeHTTP(w, r) } func handleApi404(ctx context.Context, w http.ResponseWriter, r *http.Request) { web.StdJSONErr(w, http.StatusNotFound)