This method returns a deserialized result.
For raw data see send
.
var api = new GithubAPI(get_github_oauth)
var obj = api.get("/repos/nitlang/nit")
assert obj isa Repo
assert obj.name == "nit"
Returns null
in case of error
.
obj = api.get("/foo/bar/baz")
assert obj == null
assert api.was_error
assert api.last_error isa GithubError
# Execute a GET request on Github API.
#
# This method returns a deserialized result.
#
# For raw data see `send`.
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
# var obj = api.get("/repos/nitlang/nit")
# assert obj isa Repo
# assert obj.name == "nit"
# ~~~
#
# Returns `null` in case of `error`.
#
# ~~~nitish
# obj = api.get("/foo/bar/baz")
# assert obj == null
# assert api.was_error
# assert api.last_error isa GithubError
# ~~~
fun get(path: String, headers: nullable HeaderMap, data: nullable String): nullable Object do
return deserialize(send("GET", path, headers, data))
end
lib/github/api.nit:152,2--175,4
# If no cache data is found for `key` then json is loaded from Github API.
redef fun get(key, headers, data) do
if not enable_cache then return super
if store.has_key(key) then
# print "Get {key} (cache)" # debug
was_error = false
return deserialize(store.load_object(key).to_json)
end
var obj = super
if not was_error and obj isa Serializable then
cache(key, obj)
end
return obj
end
lib/github/cache.nit:57,2--70,4