diff --git a/API.md b/API.md index f42c0a79..6ffc76f9 100644 --- a/API.md +++ b/API.md @@ -7,6 +7,8 @@ In older versions of Mete, this was located at `/`. Some installations may have not yet been upgraded. Please be prepared. Some already upgraded installations may provide legacy support at `/`, but please don't depend on this. +If you want to setup those for your own installation, please take a look at + [`v1-rewrite.md`](https://github.com/chaosdorf/mete/blob/master/v1-rewrite.md). (Implementing upcoming versions of the specification would be great, too.) For each of these endpoints there's one without the suffix `.json` located at `/`, diff --git a/v1-rewrite.md b/v1-rewrite.md new file mode 100644 index 00000000..81cfb1ba --- /dev/null +++ b/v1-rewrite.md @@ -0,0 +1,75 @@ +# Rewrite rules providing support for legacy clients # + +For a long time, the API wasn't properly specified. +Yet, people went ahead and built clients which are probably still in use today. + +If you want to support them with a recent version of Mete, +you can apply those rewrite rules to a web server of your choice. +You may need to adjust them to your setup. + +Be advised that really old clients (eg. Meteroid before v1.9) +might break in future Mete versions (because they use `/user/{id}/deposit`). + +## General rules ## + +``` +/audits.json -> /api/v1/audits.json +/barcodes.json -> /api/v1/barcodes.json +/barcodes/new.json -> /api/v1/barcodes/new.json +/barcodes/{id}.json -> /api/v1/barcodes/{id}.json +/drinks.json -> /api/v1/drinks.json +/drinks/new.json -> /api/v1/drinks/new.json +/drinks/{id}.json -> /api/v1/drinks/{id}.json +/users.json -> /api/v1/user.json +/users/new.json -> /api/v1/users/new.json +/users/{id}.json -> /api/v1/users/{id}.json +/users/{id}/deposit.json -> /api/v1/users/{id}/deposit.json +/users/{id}/payment.json -> /api/v1/users/{id}/payment.json +/users/{id}/buy.json -> /api/v1/users/{id}/buy.json +/users/{id}/buy_barcode.json -> /api/v1/users/{id}/buy_barcode.json +/users/stats.json -> /api/v1/users/stats.json +``` + +## Apache httpd ## + +``` +RewriteEngine on +RewriteRule ^/audits\.json$ /api/v1/audits.json +RewriteRule ^/barcodes\.json$ /api/v1/barcodes.json +RewriteRule ^/barcodes/(.*)\.json$ /api/v1/barcodes/$1.json +RewriteRule ^/drinks\.json$ /api/v1/drinks.json +RewriteRule ^/drinks/(.*)\.json$ /api/v1/drinks/$1.json +RewriteRule ^/users\.json$ /api/v1/users.json +RewriteRule ^/users/(.*)\.json$ /api/v1/users/$1.json +RewriteRule "^/(.*)" "http:///$1" [P] +ProxyPassReverse "/" "http:///" +``` + +## nginx ## + +``` +rewrite ^/audits\.json$ /api/v1/audits.json last; +rewrite ^/barcodes\.json$ /api/v1/barcodes.json last; +rewrite ^/barcodes/(.*)\.json$ /api/v1/barcodes/$1.json last; +rewrite ^/drinks\.json$ /api/v1/drinks.json last; +rewrite ^/drinks/(.*)\.json$ /api/v1/drinks/$1.json last; +rewrite ^/users\.json$ /api/v1/users.json last; +rewrite ^/users/(.*)\.json$ /api/v1/users/$1.json last; +proxy_pass http:///; +``` + +## lighttpd ## + +``` +url.rewrite-once = ( + "^/audits\.json$" => "/api/v1/audits.json", + "^/barcodes\.json$" => "/api/v1/barcodes.json", + "^/barcodes/(.*)\.json$" => "/api/v1/barcodes/$1.json", + "^/drinks\.json$" => "/api/v1/drinks.json", + "^/drinks/(.*)\.json$" => "/api/v1/drinks/$1.json", + "^/users\.json$" => "/api/v1/users.json", + "^/users/(.*)\.json$" => "/api/v1/users/$1.json" +) +proxy.server = ( "" => ( ( "host" => "", "port" => "" ) ) ) +``` +