Compare commits
No commits in common. "38854d5461aa95106e0201fc44a396e1b0f8fe2e" and "3ed669f5606e81adbf4713b108aa1fb8a428075b" have entirely different histories.
38854d5461
...
3ed669f560
|
@ -154,7 +154,6 @@ func handler(opts Opts, f http.HandlerFunc) http.HandlerFunc {
|
||||||
// TODO make this more real
|
// TODO make this more real
|
||||||
return func(w http.ResponseWriter, req *http.Request) {
|
return func(w http.ResponseWriter, req *http.Request) {
|
||||||
opts.Log(req.URL.Path)
|
opts.Log(req.URL.Path)
|
||||||
// TODO add user info to opts
|
|
||||||
f(w, req)
|
f(w, req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,19 +189,9 @@ func writeErrorResponse(w http.ResponseWriter, code int, resp BBJResponse) {
|
||||||
|
|
||||||
func setupAPI(opts Opts) {
|
func setupAPI(opts Opts) {
|
||||||
|
|
||||||
http.HandleFunc("/instance_info", handler(opts, func(w http.ResponseWriter, req *http.Request) {
|
http.HandleFunc("/instance", handler(opts, func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
type instanceInfo struct {
|
|
||||||
InstanceName string `json:"instance_name"`
|
|
||||||
AllowAnon bool `json:"allow_anon"`
|
|
||||||
Admins []string
|
|
||||||
}
|
|
||||||
writeResponse(w, BBJResponse{
|
writeResponse(w, BBJResponse{
|
||||||
Data: instanceInfo{
|
Data: opts.Config.InstanceName,
|
||||||
InstanceName: opts.Config.InstanceName,
|
|
||||||
AllowAnon: opts.Config.AllowAnon,
|
|
||||||
Admins: opts.Config.Admins,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -352,30 +341,4 @@ func setupAPI(opts Opts) {
|
||||||
Data: true,
|
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