From ca118d0638d50d54203ffd11e7f68a52fab5714b Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Mon, 7 Jan 2013 07:55:07 -0800 Subject: [PATCH] added api to see creds --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 7b14615..4509470 100644 --- a/main.go +++ b/main.go @@ -46,6 +46,14 @@ func passHandler(resp http.ResponseWriter, req *http.Request) { http.Redirect(resp, req, "/", http.StatusTemporaryRedirect) } +func credHandler(resp http.ResponseWriter, req *http.Request) { + b, err := json.Marshal(creds) + if err != nil { + log.Fatal(err) + } + resp.Write(b) +} + func init_db() { b, err := ioutil.ReadFile(*db_file) if err != nil { @@ -63,6 +71,7 @@ func main() { init_db() http.HandleFunc("/", homeHandler) http.HandleFunc("/pass", passHandler) + http.HandleFunc("/api/1.0/creds/", credHandler) http.Handle("/s/", http.StripPrefix("/s/", http.FileServer(http.Dir(*static_files)))) if err := http.ListenAndServe(*addr, nil); err != nil {