Browse Source

added /map[s] route to the README

Issue #14
master
Blaine Motsinger 1 year ago
parent
commit
5780ef4f27
1 changed files with 127 additions and 0 deletions
  1. 127
    0
      README.md

+ 127
- 0
README.md View File

@@ -318,6 +318,133 @@ Content-Type: text/plain
point was inserted correctly
```

### options /maps

This method returns the Allow header indicating which methods are available for the maps endpoint.

#### PARAMETERS

None.

#### RETURNS

The Allow header indicating GET and OPTIONS are available methods.

```
$ curl -sD - -X OPTIONS server:5000/api/maps
HTTP/1.0 200 OK
Date: Wed, 25 Jul 2018 19:51:40 GMT
Server: HTTP::Server::PSGI
Server: Perl Dancer2 0.206000
Allow: GET,OPTIONS
Content-Length: 0
Content-Type: text/html
```

### get /maps

This method returns all of the maps from the db table. Optional parameters filter the data returned.

#### PARAMETERS

##### id

The id matching the point.

##### name

The string name.

##### description

The string description.

##### user_id

The user_id who created the maps.

#### RETURNS

JSON datastructure, with 'maps' key, containing map objects. The objects contain key value pairs of the db table columns and values.

```
$ curl -sD - -X GET server:5000/api/maps
```
```
$ curl -sD - -X GET server:5000/api/maps?user_id=1&description=test
```

### options /map

This method returns the Allow header indicating which methods are available for the map endpoint.

#### PARAMETERS

None.

#### RETURNS

The Allow header indicating POST and OPTIONS are available methods.

```
$ curl -sD - -X OPTIONS server:5000/api/map
HTTP/1.0 200 OK
Date: Wed, 25 Jul 2018 19:51:40 GMT
Server: HTTP::Server::PSGI
Server: Perl Dancer2 0.206000
Allow: POST,OPTIONS
Content-Length: 0
Content-Type: text/html
```

### post /map

This method stores a new map into the db table.

#### PARAMETERS

##### api-key

The api-key header with value matching what's stored in the user_keys table.

##### name

The string name of the map to add.

##### description

The string description of the map to add.

#### RETURNS

##### 403

403 Forbidden, with string 'unauthorized', will be returned if the api-key header is missing or doesn't match.

```
$ curl -sD - -X POST server:5000/api/map
```

See the 200 RETURN example below for a complete example containing the api-key header.

##### 400

400 Bad Request, with string 'name and description values are required', will be returned if the request is missing the name and description keys in the JSON payload.

```
$ curl -sD - -X POST -H 'API-KEY: 1234567890qwerty' server:5000/api/map
```

See the 200 RETURN example below for a complete example containing the correct payload.

##### 200

200 OK, with string 'map was inserted correctly', will be returned if the request contains all of the required parts as descripted above.

```
$ curl -sD - -X POST -H 'API-KEY: 1234567890qwerty' -d '{"name":"test point","description":"test description"}' server:5000/api/map
```

## LICENSE AND COPYRIGHT

This software is available under the MIT license.

Loading…
Cancel
Save