background preloader

Server

Facebook Twitter

The HTTP OPTIONS method and potential for self-describing RESTful APIs | zacstewart.com. The OPTIONS method is a somewhat obscure part of the HTTP standard that could be used today with a strong impact on the interconnectedness of the interwebs while requiring minimal effort. It's role is well defined in RFC2616, yet no web services that I can find are taking advantage of it. To quote the spec: This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. Minimally, the response should be a 200 OK and have an Allow header with a list of HTTP methods that may be used on this resource. 200 OK Allow: HEAD,GET,PUT,DELETE,OPTIONS I've tested quite a few sites and APIs and so far, the only resources I've found that respond properly are default Apache pages. ...

GitHub responds with a 500, Reddit with 501 Not Implemented, Google maps with 405 Method Not Allowed. GitHub (to pick on someone specific. APIs should be taking advantage of this. Flatiron/restful. Node.js. Httpful: The REST Friendly PHP HTTP Client Library. Httpful is a simple, chainable, readable PHP library intended to make speaking HTTP sane. It lets the developer focus on interacting with APIs instead of sifting through curl set_opt pages and is an ideal PHP REST client. Httpful includes... Readable HTTP Method Support (GET, PUT, POST, DELETE, HEAD, and OPTIONS) Custom Headers Automatic "Smart" Parsing Automatic Payload Serialization Basic Auth Client Side Certificate Auth Request "Templates" Here's a quick snippet to whet your appetite. Search the Twitter API. Note the chaining, the albeit trivial custom header (for the sake of demoing), and the automatic parsing based on Content-Type of response. Install Option 1: Phar IDEAL FOR: Quick hacking or small projects Httpful provides a PHP Archive file that includes the entire library.

Install Option 2: Composer IDEAL FOR: Projects that already support Composer, the sane alternative to PEAR. Composer is starting to emerge as the true people's package manager for PHP. Get & Parse JSON Get XML. Présentation de Node.JS et du framework Express « naholyr.fr. Je me rends compte que dans ce blog je vous parle de Node.JS et d’Express, sans vous avoir jamais présenté ces technologies. Allez, revenons vite fait aux bases Installation Pour l’installation, je vous renvoie au site officiel, ou à un article en français par Atinux, mais globalement l’installation se résume à ces 3 lignes: Présentation de Node.JS Node.JS est un projet open-source se basant sur le moteur « V8″ de Chrome (il existe un fork « SpiderNode » par Mozilla, basé sur leur moteur SpiderMonkey).

Il s’agit donc finalement d’un simple interpréteur Javascript, exécutable, et enrichissant le langage avec sa propre API (accès au système de fichier, à la couche réseau, etc.). Tout ça tombe bien, les gens du Web a priori savent déjà un peu utiliser Javascript Il y a un exemple de serveur http sur la page d’accueil, donc pour changer je vous mets un exemple de requête vers une base de données utilisant node-mysql illustrant une série d’appels asynchrones: Les modules Les dépôts de modules: NPM.