1
0
Fork 0

Assert mr API

master
dump_stack() 2023-05-11 11:54:35 +00:00
parent 1b68fc571f
commit c3042c97f0
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package mr
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
@ -117,6 +118,14 @@ func GetInfo(hash string) (info Info, err error) {
query := fmt.Sprintf("%s/file/%s/info", apiURL,
url.QueryEscape(hash),
)
err = getJson(query, &info)
if err != nil {
return
}
if len(info.Result) != 1 {
err = errors.New("API mismatch")
}
return
}