diff --git a/server/cmd/main.go b/server/cmd/main.go index da04b5d..02b17cb 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -154,6 +154,7 @@ func handler(opts Opts, f http.HandlerFunc) http.HandlerFunc { // TODO make this more real return func(w http.ResponseWriter, req *http.Request) { opts.Log(req.URL.Path) + // TODO add user info to opts f(w, req) } } @@ -351,4 +352,30 @@ func setupAPI(opts Opts) { Data: true, }) })) + + http.HandleFunc("/thread_index", handler(opts, func(w http.ResponseWriter, req *http.Request) { + db := opts.DB + rows, err := db.Query("SELECT * FROM threads JOIN messages ON threads.thread_id = messages.thread_id") + if err != nil { + serverErr(w, err) + return + } + defer rows.Close() + for rows.Next() { + var id string + err = rows.Scan(&id) + if err != nil { + serverErr(w, err) + return + } + opts.Log(id) + } + writeResponse(w, BBJResponse{Data: "TODO"}) + // TODO + })) + + http.HandleFunc("/thread_create", handler(opts, func(w http.ResponseWriter, req *http.Request) { + // TODO + writeResponse(w, BBJResponse{Data: "TODO"}) + })) }