Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect legacy endpoints #63

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/63.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The legacy `/users`, `/rooms`, and `/transactions` endpoints have been removed in this release
and now redirect to the appropriate spec'd path.
9 changes: 5 additions & 4 deletions src/app-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ export class AppService extends EventEmitter {
app.use(bodyParser.json({
limit: this.config.httpMaxSizeBytes || MAX_SIZE_BYTES,
}));

const legacyEndpointHandler = (req: Request, res: Response) => {
res.status(308).location("/_matrix/app/v1" + req.originalUrl).send({ errcode: "M_UNKNOWN", error: "This non-standard endpoint has been removed" }) };
app.get("/_matrix/app/v1/users/:userId", this.onGetUsers.bind(this));
app.get("/_matrix/app/v1/rooms/:alias", this.onGetRoomAlias.bind(this));
app.put("/_matrix/app/v1/transactions/:txnId", this.onTransaction.bind(this));
app.get("/users/:userId", this.onGetUsers.bind(this));
app.get("/rooms/:alias", this.onGetRoomAlias.bind(this));
app.put("/transactions/:txnId", this.onTransaction.bind(this));
app.get("/users/:userId", legacyEndpointHandler);
app.get("/rooms/:alias", legacyEndpointHandler);
app.put("/transactions/:txnId", legacyEndpointHandler);
app.get("/health", this.onHealthCheck.bind(this));

this.app = app;
Expand Down