github.com/go-kivik/kivik/v4@v4.3.2/x/server/utils.go (about) 1 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 // use this file except in compliance with the License. You may obtain a copy of 3 // the License at 4 // 5 // http://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 // License for the specific language governing permissions and limitations under 11 // the License. 12 13 //go:build !js 14 15 package server 16 17 import ( 18 "net/http" 19 20 "gitlab.com/flimzy/httpe" 21 22 "github.com/go-kivik/kivik/v4" 23 ) 24 25 func (s *Server) root() httpe.HandlerWithError { 26 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, _ *http.Request) error { 27 return serveJSON(w, http.StatusOK, map[string]interface{}{ 28 "couchdb": "Welcome", 29 "vendor": map[string]string{ 30 "name": "Kivik", 31 "version": kivik.Version, 32 }, 33 "version": kivik.Version, 34 }) 35 }) 36 } 37 38 func (s *Server) up() httpe.HandlerWithError { 39 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, _ *http.Request) error { 40 return serveJSON(w, http.StatusOK, map[string]interface{}{ 41 "status": "ok", 42 }) 43 }) 44 } 45 46 // activeTasks returns a list of running tasks. For now it always returns an 47 // empty list, as this server doesn't support running asynchronous tasks. But it 48 // may be expanded in the future. 49 func (s *Server) activeTasks() httpe.HandlerWithError { 50 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, _ *http.Request) error { 51 return serveJSON(w, http.StatusOK, []interface{}{}) 52 }) 53 }