Assert mr API
This commit is contained in:
parent
1b68fc571f
commit
c3042c97f0
@ -2,6 +2,7 @@ package mr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -117,6 +118,14 @@ func GetInfo(hash string) (info Info, err error) {
|
|||||||
query := fmt.Sprintf("%s/file/%s/info", apiURL,
|
query := fmt.Sprintf("%s/file/%s/info", apiURL,
|
||||||
url.QueryEscape(hash),
|
url.QueryEscape(hash),
|
||||||
)
|
)
|
||||||
|
|
||||||
err = getJson(query, &info)
|
err = getJson(query, &info)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(info.Result) != 1 {
|
||||||
|
err = errors.New("API mismatch")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user