Add time trigger cron spec examination tool (#680)

This commit is contained in:
Ta-Ching Chen
2018-06-04 19:02:54 +08:00
committed by GitHub
parent 7a7d15b50c
commit 0057270551
8 changed files with 133 additions and 40 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ func (api *API) getLogDBConfig(dbType string) logDBConfig {
func (api *API) HomeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
fmt.Fprintf(w, fission.VersionInfo().String())
fmt.Fprintf(w, fission.ApiInfo().String())
}
func (api *API) ApiVersionMismatchHandler(w http.ResponseWriter, r *http.Request) {
+24
View File
@@ -18,7 +18,9 @@ package client
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
@@ -88,3 +90,25 @@ func (c *Client) handleCreateResponse(resp *http.Response) ([]byte, error) {
body, err := ioutil.ReadAll(resp.Body)
return body, err
}
func (c *Client) ServerInfo() (*fission.ServerInfo, error) {
url := fmt.Sprintf(c.Url)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
info := &fission.ServerInfo{}
err = json.Unmarshal(body, info)
if err != nil {
return nil, err
}
return info, nil
}