summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
Diffstat (limited to 'svc')
-rw-r--r--svc/handlers.go12
-rw-r--r--svc/svc.go2
2 files changed, 13 insertions, 1 deletions
diff --git a/svc/handlers.go b/svc/handlers.go
index 5a46521..bd9ec62 100644
--- a/svc/handlers.go
+++ b/svc/handlers.go
@@ -141,6 +141,18 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) {
 		out, err = twtxtCache.QueryAllStatuses()
 		out = registry.ReduceToPage(page, out)
 
+	case "/api/plain/version":
+		etag := fmt.Sprintf("%x", sha256.Sum256([]byte(Vers)))
+		w.Header().Set("ETag", "\""+etag+"\"")
+		w.Header().Set("Content-Type", txtutf8)
+		_, err := w.Write([]byte(strings.TrimSpace("getwtxt " + Vers)))
+		if err != nil {
+			errHTTP(w, r, err, http.StatusInternalServerError)
+			return
+		}
+		log200(r)
+		return
+
 	default:
 		errHTTP(w, r, fmt.Errorf("endpoint not found"), http.StatusNotFound)
 		return
diff --git a/svc/svc.go b/svc/svc.go
index b20ac7a..8b5c113 100644
--- a/svc/svc.go
+++ b/svc/svc.go
@@ -123,7 +123,7 @@ func setEndpointRouting(api *mux.Router) {
 
 	// Specifying the endpoint with and without query information.
 	// Will return 404 on empty queries otherwise.
-	api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}").
+	api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets|version)}").
 		Methods("GET", "HEAD").
 		HandlerFunc(apiEndpointHandler)
 	api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}").