Commit 59fa0c3b authored by François Perrad's avatar François Perrad

layout doc

parent 587c928f
## Reference
# Spore.GoogleDiscovery
---
# Reference
With this module, lua-Spore becomes a
[Google APIs Client Library](http://code.google.com/apis/discovery/libraries.html)
......@@ -7,7 +11,7 @@ for Lua.
The list of supported APIs could be found
[here](http://code.google.com/apis/explorer/).
### Global Functions
## Global Functions
#### new_from_discovery( desc, [, { options }] )
......@@ -32,19 +36,19 @@ local client = discovery.new_from_discovery { api = 'urlshortener', version = 'v
Converts a [Google Discovery Document](http://code.google.com/apis/discovery/)
into a SPORE specification (both are represented by a table).
### Utilities
## Utilities
#### discovery2spore url
Converts a Google Discovery Document into a SPORE specification. By this way, the SPORE specification could be edited/modified before use.
```
```sh
$ discovery2spore https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest > urlshortener.json
```
## Examples
# Examples
### Translate "Hello World"
## Translate "Hello World"
```lua
local client = require 'Spore.GoogleDiscovery'.new_from_discovery{
......@@ -61,7 +65,7 @@ for _, v in ipairs(r.body.data.translations) do
end
```
### The Discovery of Discovery
## The Discovery of Discovery
Retrieve the list of Google APIs which are described by a Discovery Document.
......@@ -76,7 +80,7 @@ for _, item in ipairs(r.body.items) do
end
```
### URL Shortener
## URL Shortener
```lua
local client = require 'Spore.GoogleDiscovery'.new_from_discovery{
......
# lua-Spore
---
## Overview
lua-Spore is an implementation of
......@@ -25,11 +29,15 @@ lua-Spore source can be downloaded from
lua-Spore is available via LuaRocks:
luarocks install lua-spore
```sh
luarocks install lua-spore
```
or manually (LuaSocket and LuaJSON required), with:
make install
```sh
make install
```
## Test
......@@ -37,11 +45,13 @@ The test suite requires the modules lua-TestMore
[lua-TestMore](http://fperrad.github.io/lua-TestMore/)
and [lua-TestLongString](http://fperrad.github.io/lua-TestLongString).
make test
```sh
make test
```
## Copyright and License
Copyright © 2010-2015 François Perrad
Copyright © 2010-2015 François Perrad
[![OpenHUB](http://www.openhub.net/accounts/4780/widgets/account_rank.gif)](http://www.openhub.net/accounts/4780?ref=Rank)
[![LinkedIn](http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif)](http://www.linkedin.com/in/fperrad)
......
### Interface
# Spore.Middleware
---
## Interface
A middleware must use the namespace `Spore.Middleware`
and follow this caveat:
......@@ -14,7 +18,7 @@ end
return m
```
### Spore.Middleware.Auth.AWS
## Spore.Middleware.Auth.AWS
This middleware implements the authentication for Amazon Web Services, see the
[ref doc](http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html).
......@@ -37,7 +41,7 @@ client:enable('Auth.AWS', {
})
```
### Spore.Middleware.Auth.Basic
## Spore.Middleware.Auth.Basic
This middleware adds a header `authorization` in the request.
......@@ -48,7 +52,7 @@ client:enable('Auth.Basic', {
})
```
### Spore.Middleware.Auth.Bearer
## Spore.Middleware.Auth.Bearer
This middleware adds a header `authorization` in the request.
......@@ -58,7 +62,7 @@ client:enable('Auth.Bearer', {
})
```
### Spore.Middleware.Auth.DataPublica
## Spore.Middleware.Auth.DataPublica
This middleware implements the authentication for
[DataPublica](http://www.data-publica.com/content/api/).
......@@ -77,7 +81,7 @@ client:enable('Auth.DataPublica', {
})
```
### Spore.Middleware.Auth.Digest
## Spore.Middleware.Auth.Digest
This middleware adds a header `authorization` in the request
......@@ -93,7 +97,7 @@ client:enable('Auth.Digest', {
})
```
### Spore.Middleware.Auth.OAuth
## Spore.Middleware.Auth.OAuth
This middleware adds a header `authorization` in the request.
......@@ -113,7 +117,7 @@ client:enable('Auth.OAuth', {
})
```
### Spore.Middleware.Format.JSON
## Spore.Middleware.Format.JSON
This middleware encodes the parameter `payload`
and decodes the body of the response.
......@@ -126,7 +130,7 @@ with the value `application/json`.
client:enable 'Format.JSON'
```
### Spore.Middleware.Format.XML
## Spore.Middleware.Format.XML
This middleware encodes the parameter `payload`
and decodes the body of the response.
......@@ -167,7 +171,7 @@ print(to_xml(payload, {
}))
```
### Spore.Middleware.Format.YAML
## Spore.Middleware.Format.YAML
This middleware encodes the parameter `payload`
and decodes the body of the response.
......@@ -183,7 +187,7 @@ This middleware requires
client:enable 'Format.YAML'
```
### Spore.Middleware.Parameter.Default
## Spore.Middleware.Parameter.Default
This middleware set some parameters with default value.
......@@ -194,7 +198,7 @@ client:enable('Parameter.Default', {
})
```
### Spore.Middleware.Parameter.Force
## Spore.Middleware.Parameter.Force
This middleware forces some parameters.
......@@ -205,7 +209,7 @@ client:enable('Parameter.Force', {
})
```
### Spore.Middleware.Proxy.Basic
## Spore.Middleware.Proxy.Basic
This middleware handles HTTP proxy.
......@@ -221,7 +225,7 @@ client:enable('Proxy.Basic', {
client:enable 'Proxy.Basic' -- uses HTTP_PROXY=http://john:s3kr3t@proxy.myorg:8080
```
### Spore.Middleware.Cache
## Spore.Middleware.Cache
This middleware supplies a local cache (implemented with a weak table).
......@@ -231,7 +235,7 @@ client:enable 'Cache'
Note: This middleware uses only URL as unique key.
### Spore.Middleware.DoNotTrack
## Spore.Middleware.DoNotTrack
This middleware adds a header `x-do-not-track`
with the value `1` in the request.
......@@ -240,7 +244,7 @@ with the value `1` in the request.
client:enable 'DoNotTrack'
```
### Spore.Middleware.Logging
## Spore.Middleware.Logging
This middleware registers a logger in `env.sporex.logger`
for use by others middlewares.
......@@ -256,7 +260,7 @@ client:enable('Logging', {
})
```
### Spore.Middleware.Mock
## Spore.Middleware.Mock
This middleware allows to register a set of couple (condition, response).
......@@ -271,7 +275,7 @@ rules = {
client:enable('Mock', rules)
```
### Spore.Middleware.Redirection
## Spore.Middleware.Redirection
This middleware handles the header `location` in the response.
......@@ -279,7 +283,7 @@ This middleware handles the header `location` in the response.
client:enable 'Redirection'
```
### Spore.Middleware.Runtime
## Spore.Middleware.Runtime
This middleware adds a header `x-spore-runtime` (unit is seconds)
in the response.
......@@ -290,7 +294,7 @@ client:enable 'Runtime'
print(response.headers['x-spore-runtime']
```
### Spore.Middleware.UserAgent
## Spore.Middleware.UserAgent
This middleware overloads the header `useragent` in the request.
......
## Reference
# Spore
### Global Functions
---
# Reference
## Global Functions
#### new_from_spec( desc1, [desc2, ...][, { options }] )
......@@ -101,7 +105,7 @@ local client = require 'Spore'.new_from_lua{
local r = client:get_user_info{ user = 'John' }
```
### Instance Methods
## Instance Methods
These methods are inherited from `Spore.Core`
(so, do not use these name in API description).
......@@ -129,7 +133,7 @@ Removes all middlewares.
Never directly called.
### Global Variables
## Global Variables
These variables allow to do some configuration.
......@@ -158,9 +162,9 @@ require 'Spore'.methname_modifier = function (name)
end
```
## Examples
# Examples
### GitHub via http
## GitHub via http
```lua
local Spore = require 'Spore'
......@@ -177,7 +181,7 @@ print(res.headers['x-runtime']) --> 126ms
print(res.body.user.name) --> Scott Chacon
```
### GitHub via https
## GitHub via https
The HTTPS protocol requires
[LuaSec](http://github.com/brunoos/luasec).
......@@ -195,7 +199,7 @@ print(res.headers['x-runtime']) --> 126ms
print(res.body.user.name) --> Scott Chacon
```
### CouchDB
## CouchDB
This example comes from the book
[CouchDB, The Definitif Guide](http://guide.couchdb.org/draft/api.html).
......@@ -322,7 +326,7 @@ for k, v in pairs(r.body._attachments) do
end
```
### with Google & OAuth 1.0
## with Google & OAuth 1.0
This example uses the service Google URL Shortener.
......
## Reference
# Spore.WADL
---
# Reference
This module allows to use a
[Web Application Description Language](http://www.w3.org/Submission/wadl/)
......@@ -9,7 +13,7 @@ __LIMITATION__ : cross-references are not supported.
This module requires [LuaExpat](http://www.keplerproject.org/luaexpat/).
### Global Functions
## Global Functions
#### new_from_wadl( desc, [, { options }] )
......@@ -24,12 +28,12 @@ local wadl = require 'Spore.WADL'
local client = wadl.new_from_wadl 'yahoo_news_search.wadl'
```
### convert( wadl )
#### convert( wadl )
Converts a [WADL](http://www.w3.org/Submission/wadl/)
document into a SPORE specification (represented by a `table`).
### Utilities
## Utilities
#### wadl2spore url
......@@ -39,6 +43,6 @@ Converts a WADL document into a Spore Specification. By this way, the SPORE spec
$ wadl2spore yahoo_news_search.wadl > yahoo_news_search.json
```
## Examples
# Examples
Not yet.
......@@ -10,3 +10,4 @@ pages:
- Spore.GoogleDiscovery: discovery.md
- Spore.WADL: wadl.md
theme: mkdocs
copyright: Copyright © 2010-2015 François Perrad
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment