xp-framework / rest Goto Github PK
View Code? Open in Web Editor NEWREST Client and Server APIs for the XP Framework
REST Client and Server APIs for the XP Framework
Instead of gathering all results in an array I'd like to be able to return a traversable or an iterator directly and have the API handle that for me; potentially optimizing by starting direct unbuffered writes to the client.
The standard way: Fetch results, gather into array, return:
#[@webmethod(verb= 'GET')]
public function all() {
$q= $this->conn->query('select * from swarm');
$result= [];
while ($record= $q->next()) {
$result[]= $this->asResult($record);
}
return $result;
}
Together with xp-framework/rdbms#2 and data sequences, we can now write:
#[@webmethod(verb= 'GET')]
public function all() {
$q= $this->conn->query('select * from swarm');
return Sequence::of($q)->map([$this, 'asResult']);
}
If I omit the urlencode()
call in the code below I get an lang.FormatException ("" is not a valid HTTP response [-1]), which is because an invalid HTTP request is sent.
$response= $client->execute((new RestRequest('/kibana-int/dashboard/{dashboard}', 'GET'))
->withSegment('dashboard', urlencode($this->dashBoard))
->withAccept('application/json')
);
GET /kibana-int/dashboard/My example dashboard HTTP/1.1
Connection: close
Host: elk.example.com:9200
Accept: application/json
See https://travis-ci.org/xp-framework/rest/jobs/234372333
Compile error (Declaration of io\File▒336::in() must be compatible with io\File::in(): io\streams\InputStream)
This is only inside the tests, the main code works fine with PHP 7.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.