Commit Graph

332 Commits

Author SHA1 Message Date
PJ Dietz 166fc66117 Assign $_POST to parsedBody on creation if form content header is set. 2015-03-24 19:37:36 -04:00
PJ Dietz fcbdd1ebfb Read headers in ServerRequest
- Add withServerRequest
- Add updateWithServerRequest
- Add getServerRequestHeaders
2015-03-22 21:10:54 -04:00
PJ Dietz fe93ab13c1 Change Message\Message::headers from private to protected 2015-03-22 21:09:31 -04:00
PJ Dietz 51f057b300 Minor fix to Message\Request 2015-03-22 21:09:06 -04:00
PJ Dietz 513db2def1 Add Message\ServerRequest 2015-03-22 20:42:09 -04:00
PJ Dietz 734c87188f Style fixes for Message and MessageTest 2015-03-22 18:03:21 -04:00
PJ Dietz 60a0913daf Remove unused import from Response 2015-03-22 18:02:56 -04:00
PJ Dietz 292e213c0a Add Message\Request 2015-03-22 18:02:36 -04:00
PJ Dietz 197ea3000a Add Message\Response 2015-03-22 14:56:08 -04:00
PJ Dietz 60b309a3d1 Add Message\Message 2015-03-22 14:03:31 -04:00
PJ Dietz b6df67afd0 Add Iterator to HeaderCollection 2015-03-22 14:03:18 -04:00
PJ Dietz 2575bc743e Refactor HeaderCollection to store headers as string[] instead of Header[]
Remove Header
Move Header out of own namespace to Message
2015-03-22 12:05:48 -04:00
PJ Dietz a2ae6fff7d Cloning a HeaderCollection yields deep copies of the Headers. 2015-03-22 11:36:06 -04:00
PJ Dietz 3ab7c55257 Add Message\Header\HeaderCollection 2015-03-22 09:38:18 -04:00
PJ Dietz ba26379fdc Add Message\Header\Header 2015-03-22 09:16:17 -04:00
PJ Dietz b1f8b076a7 PhpDoc cleanup 2015-03-08 17:36:36 -04:00
PJ Dietz f08691fff1 Allow template variables to be named as alpha followed by alphanumeric and underscore. 2015-03-08 14:59:32 -04:00
PJ Dietz 81ce6dae9d Add additional HttpExceptions 2015-03-04 20:59:52 -05:00
PJ Dietz 2aadfe74b3 Code cleanup 2015-03-04 19:06:16 -05:00
PJ Dietz fdeff57a79 Prevent Router from trying to call respond on non responses. 2015-02-22 17:17:56 -05:00
PJ Dietz 13e683225d Fix PhpDoc errors 2015-02-22 14:44:20 -05:00
PJ Dietz a5c180dace Code inspection 2015-02-22 14:10:15 -05:00
PJ Dietz 1a5712a417 Split tests into unit and integration test suites 2015-02-22 14:05:05 -05:00
PJ Dietz 812012bdbf Propagate $request and $args to route and errorHandler callables 2015-02-22 12:01:21 -05:00
PJ Dietz d785e21fee Propagate arguments to callable in HandlerUnpacker::unpack 2015-02-22 09:08:15 -05:00
PJ Dietz 64ef9cc4e7 Update copyright and rename a couple tests 2015-02-21 16:01:06 -05:00
PJ Dietz b582fcf546 Deprecate RouteBuilder 2015-02-21 15:59:27 -05:00
PJ Dietz 614da5f2ff Update tests for messages. 2015-02-21 15:59:08 -05:00
PJ Dietz d4ad282abc Update tests for Client and Handler 2015-02-21 14:51:42 -05:00
PJ Dietz 5dacb232ec Updates to Router
- Add Router::add method
- Refactor Router to contain one RouteTable
2015-02-21 14:11:53 -05:00
PJ Dietz b350693aca Rearrange Route 2015-02-21 09:52:23 -05:00
PJ Dietz 259dd0baa1 Remove RouteTable::addRoutes 2015-02-21 08:14:38 -05:00
PJ Dietz 1c82908eeb Refactor Router to use RouteTables 2015-02-21 08:10:58 -05:00
PJ Dietz 14195355e3 Add RouteTable 2015-02-21 07:13:09 -05:00
PJ Dietz 56cf56c6c5 Fix typo 2015-02-20 07:45:48 -05:00
PJ Dietz 3d68a0af86 Add RouteFactory 2015-02-20 07:45:39 -05:00
PJ Dietz 04561076d5 Update Router to work with updated Routes and ErrorHandlers
Deprecate:
	- Router::setStaticRoute
	- Router::setPrefixRoute
2015-02-19 22:04:34 -05:00
PJ Dietz 4deac492dd Update BaseRoute to use HandlerUnpacker 2015-02-19 19:59:33 -05:00
PJ Dietz 5dc5cdab06 Add HandlerUnpacker 2015-02-19 19:51:42 -05:00
PJ Dietz c38659a310 Update TemplateRoute tests 2015-02-18 21:39:07 -05:00
PJ Dietz 6859bd9707 Update RegexRoute tests 2015-02-18 21:21:56 -05:00
PJ Dietz 63fd00fff0 Update PrefixRoute tests 2015-02-18 20:47:45 -05:00
PJ Dietz 38aaf26943 Update StaticRoute tests to use Prophecy 2015-02-18 20:47:00 -05:00
PJ Dietz 9498542f30 Allow Route target to be a callable, string, or instance 2015-02-18 20:17:09 -05:00
PJ Dietz 38639d9ee4 Update TemplateRouter to better match templates with variables in more complicated paths 2015-02-02 17:08:25 -05:00
PJ Dietz 84044d5057 Re-add converting HttpExceptions to responses in Handler 2015-01-21 11:03:01 -05:00
PJ Dietz 1a88e0273d Use registered 404 error handler when no route matches in Router::respond 2015-01-21 09:51:14 -05:00
PJ Dietz ca2c8625ec Store PrefixRoutes to a separate array.
Prioritize routes in the order static, prefix, everything else.
2015-01-02 13:13:08 -05:00
PJ Dietz caef817535 Do not allow routing to continue after a dispatched StaticRoute returns null 2015-01-02 12:31:02 -05:00
PJ Dietz 78fe57d736 Store StaticRoutes to separate hash array in Router
Add StaticRouteInterface
2015-01-02 12:00:30 -05:00
Phil 6ae85398db Just making silly mistakes now... 2015-01-01 20:43:07 +00:00
Phil b6ec262d0e Forgot to catch exceptions in static routes 2015-01-01 20:38:57 +00:00
Phil 451a1c0576 Trying to stop not set error... 2015-01-01 20:27:45 +00:00
Phil aaaf644118 Initialized response to null to be safe 2015-01-01 20:21:17 +00:00
Phil bb052625af Made sure not to iterate over StaticRoutes again because the key they map to is a specific child Handler 2015-01-01 20:17:48 +00:00
Phil b0c1330a26 Optimized for static routes 2015-01-01 19:44:33 +00:00
PJ Dietz 666f45977e Merge branch 'eatonphil-master' into prefix 2015-01-01 12:43:41 -05:00
PJ Dietz 9eec436ad4 Add error handlers to Router
Move catching HttpExceptions and translating into responses from Handler to Router
2015-01-01 12:41:53 -05:00
Phil 07c55bb70b no error handlers case 2014-12-31 21:12:29 +00:00
Phil cc17ebbe48 Added support for custom error handlers 2014-12-31 21:06:06 +00:00
PJ Dietz 6d499a6643 Add PrefixRoute 2014-12-29 13:09:51 -05:00
PJ Dietz 75088499b8 Ensure $args propagate from Router to Handlers 2014-08-02 17:42:16 -04:00
PJ Dietz 512897effd Prefer apache_request_headers when reading request headers.
Apache does not pass the Authorization header through to PHP as
$_SERVER["HTTP_AUTHORIZATION"], so reading from $_SERVER is not viable
with Apache.
2014-07-28 12:43:29 -04:00
PJ Dietz 46f11b2b9b Fix Request for PHP 5.3.0 compatibility 2014-07-28 10:08:27 -04:00
PJ Dietz 7d3f4442b4 Code style 2014-07-27 16:52:59 -04:00
PJ Dietz d1a77c5454 Allow * wildcard at end of URI template 2014-07-27 16:37:24 -04:00
PJ Dietz e77c85f71b Update documentation and README 2014-07-26 22:39:26 -04:00
PJ Dietz 1c5d95e727 Router::getResponse() now returns null to allow better nesting
Runs tests that output responses in process isolation
2014-07-26 19:05:38 -04:00
PJ Dietz 60eaabadd5 Update phpdoc for Client 2014-07-26 11:59:46 -04:00
PJ Dietz 4db7c8da7d Add Request::getFormFields. Add Test for sending form-encoded request 2014-07-26 11:49:15 -04:00
PJ Dietz 4ae6e5f2e4 Fix issue in Response when setting headers in constructor
Update tests for Response
2014-07-26 01:47:05 -04:00
PJ Dietz 3d1690404e Add Request::setFormFields 2014-07-26 01:20:51 -04:00
PJ Dietz 3d44d1a3f5 Test sending body with Client 2014-07-25 23:08:27 -04:00
PJ Dietz 70c2ef1150 Fix problem where Client did not set headers. 2014-07-25 14:29:04 -04:00
PJ Dietz 1a21b2b7d0 Add Client class
Move Request::request() to Client::request()
2014-07-24 20:41:32 -04:00
PJ Dietz 982e048b4f Move HttpExceptions to their own namespace 2014-07-14 01:01:41 -04:00
PJ Dietz 1e32c66cb5 Always clean body on HEAD request 2014-07-14 01:01:15 -04:00
PJ Dietz ecb58c11b8 Clean up unused imports 2014-07-14 01:00:38 -04:00
PJ Dietz b601c38d36 Add tests for Router 2014-07-14 00:19:04 -04:00
PJ Dietz 794d0901b9 Fix documentation and add tests for Response 2014-07-13 23:56:19 -04:00
PJ Dietz 581c3d1351 Update documentation and add tests for Request 2014-07-13 21:39:01 -04:00
PJ Dietz 8aa6b91d91 Update documentation on Router and Message 2014-07-13 17:41:52 -04:00
PJ Dietz 6a642dfed2 Fix documentation and add tests for BaseRoute 2014-07-13 17:18:08 -04:00
PJ Dietz e597926634 Fix documentation and add tests for TemplateRoute 2014-07-13 17:08:15 -04:00
PJ Dietz f11c13c1b3 Fix documentation and add tests for RegexRoute 2014-07-13 16:27:09 -04:00
PJ Dietz 921d84cf8b Update StaticRoute documentation and add tests 2014-07-13 15:50:30 -04:00
PJ Dietz 18d3d6c9db Update RouteBuilder docs and add test
- Remove RouteBuilder::buildRoutesFromJson()
- Allow RouteBuilder::buildRoutes() to parse JSON
- Add PHPUnit
- Add tests for RouteBuidler
- Update docs for RouteBuilder
- Update README RouteBuilder example
- Rename constant in BaseRoute
2014-07-13 14:29:37 -04:00
PJ Dietz ae9fbaa709 Add phpdoc for HttpException and subclasses. 2014-07-13 10:26:01 -04:00
PJ Dietz aec8bcca4a Fix phpdoc for interfaces, Handler. 2014-07-13 10:12:12 -04:00
PJ Dietz 3be61bfb07 Fix phpdoc in Handler 2014-07-13 09:22:13 -04:00
PJ Dietz c61b2197ea Remove @package tag from phpdoc throughout. 2014-07-13 09:00:38 -04:00
PJ Dietz d9840067db Fix typos in exception names. 2014-07-11 15:01:25 -04:00
PJ Dietz 47fdc0e31b Add HTTP Exceptions and convert to responses in Handler 2014-07-10 22:47:05 -04:00
PJ Dietz 25c423e0ee Simplify Request::getRequestHeaders() 2014-07-08 20:21:23 -04:00
PJ Dietz 08cf2f4ec2 Fix typos 2014-06-29 10:51:51 -04:00
PJ Dietz aa06181e40 Refactor DispatcherInterface to HandlerInterface
Update file doc blocks
Code inspection
2014-06-29 10:43:39 -04:00
PJ Dietz 3718e03c78 Add RouteBuilder class for parsing route configurations 2014-06-29 02:11:52 -04:00
PJ Dietz 12b971dfe6 Add convenience methods to Router
Code cleanup and inspection
2014-06-28 20:12:55 -04:00
PJ Dietz f60b010f11 Update Router class to match new DispatcherInterface 2014-06-28 20:03:36 -04:00
PJ Dietz 8f99b88d09 Reduce number of interfaces and classes
Remove RouterInterface, Route, and RouteTarget
Change signature of DispatcherInterface::getResponse() to include args
Update classes to match new DispatcherInterface::getResponse()

This update simplifies the API significantly with most classes now
simply needing to implement DispatcherInterface
2014-06-28 19:42:05 -04:00
PJ Dietz 618058850d Add Route classes
Route is now replaced with several classes descending from BaseRoute.
Each of these routes takes care of autoloading and instantiated the
RouteTargetInterface instead of leaving that to the Router.
2014-06-28 18:44:09 -04:00
PJ Dietz 086dd62f05 Bugfixes from removing magic methods 2014-06-28 18:30:27 -04:00
PJ Dietz c1937e8a33 Remove magic methods from Message 2014-06-28 16:24:16 -04:00
PJ Dietz 566384f1e4 Promote Response::getStatusLine() to public
Fix issue where response phrase was not set in Response constructor.
2014-04-07 16:25:22 -04:00
PJ Dietz 8049635837 Add ability to read response body from a file without reading the entire file into memory 2014-03-19 15:13:29 -04:00
PJ Dietz a756adf933 Update RequestInterface to inherit from RouteableInterface 2013-08-25 23:05:13 -04:00
PJ Dietz e3e98377c3 Track route depth on the Request, not on the Router.
This allows a Handler to use the top-level router and have the depth count match the depth for the current request, not the total.
2013-08-16 18:59:05 -04:00
PJ Dietz d91ac12541 Add safeguard against infinite routing loops 2013-08-16 17:49:37 -04:00
PJ Dietz 6013198436 Allow Routers to dispatch additional Routers
- RouterInterface and HandlerInterface now share a parent, RouteTargetInterface.
- A Router may now be used as the target for a Route.
- Route's handler member is not replaced by Router's target member.
- Route::getHandler() and Route::setHandler() are deprecated and alias getTarget() and setTarget()
2013-08-16 16:51:09 -04:00
PJ Dietz dbd4ff96a5 Split response into headers and body based on the size of the headers cURL reports.
Fixes an issue with 100 Continue status codes, etc. where r\n\r\n appears within the list of headers.
2013-08-14 10:47:02 -04:00
PJ Dietz fef677168e Allow Request::readHttpRequest to work when apache_request_headers is not available. 2013-06-12 19:54:08 -04:00
PJ Dietz e693e138d0 Add support for OPTIONS and generate Allow header from Handler. Close #4 2013-05-27 14:13:16 -04:00
PJ Dietz fafce16e9e Update README. Add default 500 error to Router. Close #3 2013-05-27 12:59:55 -04:00
PJ Dietz 8aae07660c Add port to Request class. Allow user to supply cURL options. Close #2
Caller can now supply array of options for use with curl_setopt_array() when calling Request::request()
2013-05-26 18:32:26 -04:00
PJ Dietz 98e04ab63b Define interfaces more clearly and clean up code. 2013-05-26 14:55:48 -04:00
PJ Dietz ac752bb446 Add interfaces for requests and responses 2013-05-23 20:26:32 -04:00
PJ Dietz b28b53aa11 Add interfaces for Route and Handler 2013-05-23 19:49:43 -04:00
PJ Dietz 47ec8f5f96 Code cleanup and refactoring 2013-05-19 12:59:57 -04:00
PJ Dietz 3018d4c660 Fix typo 2013-03-29 14:00:45 -04:00
PJ Dietz 9863bee7f5 Set headers and headerLookup arrays in Message::__constructor to prevent warning 2013-03-29 13:53:51 -04:00
PJ Dietz 972f8e9c26 Update Request and Response
Add constructor for Request to provide URI and method on instantiation.
Add success property and getSuccess() method Response.

Closes #1
2013-03-26 21:05:36 -04:00
PJ Dietz d0ef6a62fb Updates to documentation for better documentation generation
Refactored WellrestedException to WellRESTedException
2013-01-29 20:59:55 -05:00
PJ Dietz 4285636088 Merge branch 'master' of git://github.com/pjdietz/WellRESTed
Conflicts:
	src/pjdietz/WellRESTed/Message.php
2013-01-28 22:24:54 -05:00
PJ Dietz e419aaba7d Add page-level doc blocks to each script
Update comments
Update magic accessors
Update accessor and add islet and unset methods
2013-01-28 22:15:33 -05:00
PJ Dietz 1bad8e35a0 Send headers when making a request.
Add headerLines property to Message
Remove invalid default value for protocol in Response
2013-01-28 15:53:18 -05:00
PJ Dietz a44c98efb3 Fix error in Request.php where wrong namespace was used for Exceptions
Remove sample APi
2013-01-27 18:07:07 -05:00
PJ Dietz 871f76f008 Update documentation
Add config file for Doxygen
2013-01-27 14:14:45 -05:00
PJ Dietz 22db41c0e5 Rename Exceptions directory to match namespace spelling. 2013-01-27 10:03:22 -05:00
PJ Dietz 298bdab35f Update Router and Route to require autoloading
Update samples to use new Router and Route
Refactor ApiSample namespace
2013-01-24 21:48:44 -05:00
PJ Dietz 8597b9be06 Refactor for better PSR compliance. Still need to finish with samples. 2013-01-24 21:27:57 -05:00
PJ Dietz 3ff2371edd Make specifying the path to the handler script optional in Route since it is not needed if using an autoloader. 2013-01-10 21:21:57 -05:00
PJ Dietz 331bdae7ec Refactor library files into src/pjdietz/WellRESTed 2013-01-10 20:54:22 -05:00