Last active
March 17, 2016 22:21
-
-
Save mpl/e744ecbede9e9807d41e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Go side: | |
func main() { | |
js.Global.Set("HasGopherJS", true) | |
js.Global.Set("http", map[string]interface{}{ | |
"GetFileTree": GetFileTree, | |
}) | |
} | |
func GetFileTree(dirRef string) { | |
println("IN GETFILETREE") | |
_, ok := blob.Parse(dirRef) | |
if !ok { | |
println(fmt.Sprintf("%q not a valid blobRef", dirRef)) | |
return | |
} | |
println("BLOB PARSING OK") | |
resp, err := http.Get("http://localhost:3179/ui/tree/"+dirRef) | |
if err != nil { | |
println(fmt.Sprintf("error fetching file tree for directory %v: %v", dirRef, err)) | |
return | |
} | |
println("GET OK") | |
defer resp.Body.Close() | |
data, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
println(fmt.Sprintf("error reading file tree for directory %v: %v", dirRef, err)) | |
return | |
} | |
println("READ OK") | |
println(data) | |
} | |
js side: | |
if (HasGopherJS) { | |
http.GetFileTree(this.props.meta.blobRef); | |
return | |
} | |
output: | |
xhrio.js:557 XHR finished loading: POST "http://localhost:3179/my-search/camli/search/query". | |
2016-03-17 17:53:52.292 gopherjs.js:82450 IN GETFILETREE | |
2016-03-17 17:53:52.294 gopherjs.js:82461 BLOB PARSING OK | |
2016-03-17 17:53:52.305 | |
gopherjs.js:1420 Uncaught null | |
$callDeferred @ gopherjs.js:1420 | |
$panic @ gopherjs.js:1443 | |
$throwRuntimeError @ gopherjs.js:2364 | |
$block @ gopherjs.js:1541 | |
$recv @ gopherjs.js:1594 | |
$packages.honnef.co/go/js/xhr.Request.ptr.Send @ gopherjs.js:82345 | |
$packages.honnef.co/go/js/xhr.Send @ gopherjs.js:82362 | |
$packages.camlistore.org/server/camlistored/ui/gopherjs.GetFileTree @ gopherjs.js:82462 | |
v.$externalizeWrapper @ gopherjs.js:1865 | |
cam.DirectoryDetail.React.createClass.componentWillMount @ directory_detail.js:53 | |
(anonymous function) @ react-with-addons.js:5944 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment