summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2014-05-21 20:06:14 +0200
committerJakob Borg <jakob@nym.se>2014-05-21 20:06:14 +0200
commit6fb05fc82a0f146a706dda790ed5b17764b226ff (patch)
treeb7ebef76d9b5eea65aae0a9dbe56776e8d96561d /cmd
parent423517596622a00c76de24b11d8a42e0b6c71806 (diff)
Add Edit > Show ID with QR (fixes #243)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/syncthing/gui.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go
index 5bd57528f0..49e5b8ca0b 100644
--- a/cmd/syncthing/gui.go
+++ b/cmd/syncthing/gui.go
@@ -19,6 +19,7 @@ import (
"github.com/calmh/syncthing/logger"
"github.com/calmh/syncthing/model"
"github.com/codegangsta/martini"
+ "github.com/vitrun/qart/qr"
)
type guiError struct {
@@ -80,6 +81,7 @@ func startGUI(cfg config.GUIConfiguration, m *model.Model) error {
router.Get("/rest/system", restGetSystem)
router.Get("/rest/errors", restGetErrors)
router.Get("/rest/discovery", restGetDiscovery)
+ router.Get("/qr/:text", getQR)
router.Post("/rest/config", restPostConfig)
router.Post("/rest/restart", restPostRestart)
@@ -289,6 +291,17 @@ func restGetDiscovery(w http.ResponseWriter) {
json.NewEncoder(w).Encode(discoverer.All())
}
+func getQR(w http.ResponseWriter, params martini.Params) {
+ code, err := qr.Encode(params["text"], qr.M)
+ if err != nil {
+ http.Error(w, "Invalid", 500)
+ return
+ }
+
+ w.Header().Set("Content-Type", "image/png")
+ w.Write(code.PNG())
+}
+
func basic(username string, passhash string) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
error := func() {