Skip to content

Commit

Permalink
Make api more restful
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacJChen authored and thehenrytsai committed Jun 4, 2020
1 parent f2cfb1f commit 0fafadb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ app.use(async (ctx, next) => {
});

const router = new Router();
router.post('/', async (ctx, _next) => {
router.post('/operations', async (ctx, _next) => {
const response = await sidetreeCore.handleOperationRequest(ctx.body);
setKoaResponse(response, ctx.response);
});
Expand All @@ -56,9 +56,10 @@ router.get('/version', async (ctx, _next) => {
setKoaResponse(response, ctx.response);
});

router.get('/:did', async (ctx, _next) => {
// Strip away the first '/' character.
const didOrDidDocument = ctx.url.slice(1);
const resolvePath = '/identifiers/';
router.get(`${resolvePath}:did`, async (ctx, _next) => {
// Strip away the first '/identifiers/' string.
const didOrDidDocument = ctx.url.split(resolvePath)[1];
const response = await sidetreeCore.handleResolveRequest(didOrDidDocument);
setKoaResponse(response, ctx.response);
});
Expand Down

0 comments on commit 0fafadb

Please sign in to comment.