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

Set DID Resolution Result media type #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ 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);
const koaResponse = ctx.response;
koaResponse.status = SidetreeResponse.toHttpStatus(response.status);

if (!response.body) {
koaResponse.body = '';
} else {
koaResponse.set('Content-Type', 'application/ld+json;profile="https://w3id.org/did-resolution";charset=utf-8');
// Stringify the result as otherwise the Content-Type gets overridden to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you reverse line 78 and 81? If works, it would be nicer to refactor setKoaResponse() to take in optional headers to set.

// application/json.
koaResponse.body = JSON.stringify(response.body);
}
});

router.get('/monitor/operation-queue-size', async (ctx, _next) => {
Expand Down