RESTmini

Categories

Component ID

2346199

Component name

RESTmini

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

2611

Component created

Component changed

Component body

Lightweight REST service API which features simple configuration and full error handling.
Also provides a REST client.

Extensive error handling and logging

One of the main goals of RESTmini is that you as developer or site maintainer should be told if-and-how something is misconfigured, or otherwise behaves erroneously.

Getting acquainted with RESTmini Service

  1. install the RESTmini Service Example (restmini_service_example) module
  2. check that the Example endpoints are enabled: /admin/config/restmini/service_endpoints
  3. open console on the web server, execute the Example's test:
    drush restmini-service-test 'http://ser.ver' 'restmini_service_example' --output-target=watchdog
  4. check watchdog logs

Lightweight as in...

  • implementing one simple info hook - hook_restmini_service()
  • an endpoint callback (function or static class method) automatically receives all/any/no path arguments that a request sends:
    - no need to write complex configuration that defines which path args will be listened to
  • pretty much the same goes for GET and POST args:
    - no configuration, just listen to the ones that you expect or require
  • just return the payload - the service module's router will figure out how to respond appropriately - or (for more control) respond via the respond and error functions

Automated input parameters validation

The hook_restmini_service() does not require declaration of input parameters.
But, if the parameters are declared for an operation, the operation callback may validate input arguments by calling
RestMiniService::importArguments($validationFailures);

Simple but powerful test framework

Implement hook_restmini_service_test() declaring one or more tests, containing one or more steps.
The result of a request is usable for later requests - thus a test may reflect a realistic workflow sequence.

Chainable REST client

RESTmini Client is a cURL based HTTP requester - simple, yet highly configurable.
And chainable, like Drupal's database methods.
Provides several means of getting details about the nature of the service response. And also usable against services that send wrong status codes and misleading content-type headers.

What's not in the package

Integration with Drupal nodes, entities, fields etc. For lot's of REST services there's no point in taking the long way around not-so-transparent APIs.
Non-JSON service response. The service module only speaks JSON, whereas the client speaks any language, as long as you provide a parser.

Sponsorship

RESTmini is sponsored by Københavns Kommune, Koncernservice (Copenhagen Municipality, Corporate Services).

Similar modules



Documentation

Requirements

PHP 5.3+