package api import ( "encoding/json" "fmt" "net/http" ) func RegisterMiscEndpoints() { http.HandleFunc("/opal", EndpointOpal) } type endpointOpalResponse struct { ServerApi string ApiVersion string } // GET /opal func EndpointOpal(w http.ResponseWriter, r *http.Request) { var ret endpointOpalResponse ret.ServerApi = "Opal" ret.ApiVersion = "0.0.1" retJson, err := json.Marshal(ret) if err != nil { fmt.Println("API warning: failed to marshal /opal response") http.Error(w, "Internal server error", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") w.Write(retJson) }