Skip to content

Commit

Permalink
Add how to define new endpoints in web for api-versioning.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Jan 3, 2025
1 parent 2fc0ea5 commit 80695aa
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion rfd/0179-api-versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ func (h *Handler) getFoos() (interface{}, error) {
}
```

#### Defining new endpoints in the web client
All endpoints should be defined in a JS object, similary done [here](https://github.com/gravitational/teleport.e/blob/ebf079267020d59f14353dd3495b4fd783339fa5/web/teleport/src/config.ts#L134).

This helps us tell apart same paths but with different HTTP verbs.

Example of a new single endpoint:

```ts
user: {
create: '/v1/webapi/users',
}
```

Example of an endpoint with same paths but with different verbs:

```ts
user: {
create: '/v1/webapi/users',
update: '/v1/webapi/users',
}
```

Example of creating a version N endpoint:
```ts
user: {
// TODO(<your-github-handle>): DELETE IN 18.0 - replaced by /v2/webapi/users
create: '/v1/webapi/users',
createV2: '/v2/webapi/users',
}
```

### Removing an endpoint
An endpoint can be removed in a major version n+2, where n is the last major
version where the endpoint was used.
Expand Down Expand Up @@ -269,4 +300,4 @@ tab was available in clients that _may_ have been communicating with proxies
older than the required version. So a check was made to see if that proxy
supported pinned resources, and if it wasn't, made the error known to the user
that "Pinned Resources is supported by proxies version 14.1+" (or something like
that).
that).

0 comments on commit 80695aa

Please sign in to comment.