Skip to content

Commit

Permalink
Give advice about rewrites for old clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
YtvwlD committed Oct 2, 2017
1 parent fdac328 commit 450a146
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `/`,
Expand Down
75 changes: 75 additions & 0 deletions v1-rewrite.md
Original file line number Diff line number Diff line change
@@ -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://<mete>/$1" [P]
ProxyPassReverse "/" "http://<mete>/"
```

## 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://<mete>/;
```

## 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" => "<mete host>", "port" => "<mete port>" ) ) )
```

0 comments on commit 450a146

Please sign in to comment.