Back to EIP
Message Store
⋯
service /api on new http:Listener(8080) {
resource function get location(string address) returns GeoCodeResponse|error {
GeoCodeResponse|error storedGeocode = firebaseClient->/location/[address]/location\.json();
if storedGeocode !is error {
return storedGeocode;
}
GeoCodeResponse geocode = check geoCodingClient->/maps/api/geocode/'json(place = address);
var _ = start storeAddress(address, geocode);
return geocode;
}
}
function storeAddress(string address, GeoCodeResponse geocode) returns error? {
_ = check firebaseClient->/location/[address]/location\.json.put(geocode, targetType = json);
}