From 8e27eeaa1c18bb7b441fe04721a9023526ce2cfb Mon Sep 17 00:00:00 2001 From: Bill Katz Date: Wed, 5 Apr 2017 18:19:34 -0400 Subject: [PATCH] add /api/server/note endpoint and support in config TOML --- config-full.toml | 2 ++ server/server_local.go | 1 + server/web.go | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/config-full.toml b/config-full.toml index a19a0a09..c0232bf3 100644 --- a/config-full.toml +++ b/config-full.toml @@ -10,6 +10,8 @@ webClient = "/path/to/webclient" # to return Timing-Allow-Origin headers in response # allowTiming = true +note = "you can put anything you want in here and have it available via /api/server/note" + # How new data instance ids are generated. # Is one of "random" or "sequential". If "sequential" can set "start_instance_id" property. # Use of "random" is a cheap way to have multiple frontend DVIDs use a shared store without diff --git a/server/server_local.go b/server/server_local.go index 8791ed95..74a8f773 100644 --- a/server/server_local.go +++ b/server/server_local.go @@ -121,6 +121,7 @@ type serverConfig struct { RPCAddress string WebClient string AllowTiming bool + Note string IIDGen string `toml:"instance_id_gen"` IIDStart uint32 `toml:"instance_id_start"` diff --git a/server/web.go b/server/web.go index 75fbad63..db9ecc3f 100644 --- a/server/web.go +++ b/server/web.go @@ -106,6 +106,10 @@ const WebHelp = ` Returns JSON for server properties. + GET /api/server/note + + Returns any value of [server.note] from the configuration TOML. + GET /api/server/types Returns JSON with the datatypes of currently stored data instances. Datatypes are represented @@ -517,6 +521,8 @@ func initRoutes() { mainMux.Get("/api/server/info", serverInfoHandler) mainMux.Get("/api/server/info/", serverInfoHandler) + mainMux.Get("/api/server/note", serverNoteHandler) + mainMux.Get("/api/server/note/", serverNoteHandler) mainMux.Get("/api/server/types", serverTypesHandler) mainMux.Get("/api/server/types/", serverTypesHandler) mainMux.Get("/api/server/compiled-types", serverCompiledTypesHandler) @@ -932,6 +938,11 @@ func serverInfoHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, jsonStr) } +func serverNoteHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + fmt.Fprintf(w, tc.Server.Note) +} + func serverTypesHandler(w http.ResponseWriter, r *http.Request) { jsonMap := make(map[dvid.TypeString]string) typemap, err := datastore.Types()