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 {