WIP starting on thread creation/index; need to parse auth info from header
parent
d22be08044
commit
38854d5461
|
@ -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"})
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue