mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
35 lines
699 B
Go
35 lines
699 B
Go
|
package operation
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"net/url"
|
||
|
"pkg/storage"
|
||
|
"pkg/util"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type Location struct {
|
||
|
Url string "url"
|
||
|
PublicUrl string "publicUrl"
|
||
|
}
|
||
|
type LookupResult struct {
|
||
|
Locations []Location "locations"
|
||
|
Error string "error"
|
||
|
}
|
||
|
|
||
|
func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
|
||
|
values := make(url.Values)
|
||
|
values.Add("volumeId", vid.String())
|
||
|
jsonBlob, err := util.Post("http://"+server+"/dir/lookup", values)
|
||
|
fmt.Println("Lookup Result:", string(jsonBlob))
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var ret LookupResult
|
||
|
err = json.Unmarshal(jsonBlob, &ret)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &ret, nil
|
||
|
}
|