added api to see creds

This commit is contained in:
Stephen McQuay 2013-01-07 07:55:07 -08:00
parent 4e5f3a0133
commit ca118d0638
1 changed files with 9 additions and 0 deletions

View File

@ -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 {