examples/appnet-api-server/src/main/java/com/hedera/hashgraph/identity/hcs/example/appnet/handlers/DidHandler.java
/**
   * Extracts the DID to be resolved from the request body.
   * Then tries to resolve it against appnet's local storage.
   * Responds with HTTP 200 OK and DID document in response body if resolution succeded.
   * Otherwise responds with HTTP 404 NOT FOUND and empty body.
   *
   * @param ctx  The HTTP context.
   * @param json The request body as JSON string.
   */
Extracts the DID to be resolved from the request body.
Then tries to resolve it against appnet's local storage.
Responds with HTTP 200 OK and DID document in response body if resolution succeded.
Otherwise responds with HTTP 404 NOT FOUND and empty body.

@param ctx  The HTTP context.
@param json The request body as JSON string.
Extracts the DID to be resolved from the request body . Then tries to resolve it against appnet ' s local storage . Responds with HTTP 200 OK and DID document in response body if resolution succeded . Otherwise responds with HTTP 404 NOT FOUND and empty body . @param ctx The HTTP context . @param json The request body as JSON string .
private void resolveDid(final Context ctx, final String json) {
    try {
      DidResolutionRequest request = JsonUtils.getGson().fromJson(json, DidResolutionRequest.class);
      String result = "";
      HcsDidMessage didMessage = storage.resolveDid(request.getDid());
      if (didMessage == null || DidMethodOperation.DELETE.equals(didMessage.getOperation())) {
        ctx.getResponse().status(Status.NOT_FOUND);
      } else {
        result = didMessage.getDidDocument();
      }
      ctx.render(result);
    } catch (JsonSyntaxException ex) {
      ctx.getResponse().status(Status.BAD_REQUEST);
      ctx.render(Jackson.json(new ErrorResponse("Invalid request body", ex)));
    } catch (Exception e) {
      ctx.getResponse().status(Status.BAD_REQUEST);
      ctx.render(Jackson.json(new ErrorResponse("Resolution failed", e)));
    }
  }
private void resolveDid ( final Context ctx , final String json ) { try { DidResolutionRequest request = JsonUtils . getGson ( ) . fromJson ( json , DidResolutionRequest . class ) ; String result = "" ; HcsDidMessage didMessage = storage . resolveDid ( request . getDid ( ) ) ; if ( didMessage == null || DidMethodOperation . DELETE . equals ( didMessage . getOperation ( ) ) ) { ctx . getResponse ( ) . status ( Status . NOT_FOUND ) ; } else { result = didMessage . getDidDocument ( ) ; } ctx . render ( result ) ; } catch ( JsonSyntaxException ex ) { ctx . getResponse ( ) . status ( Status . BAD_REQUEST ) ; ctx . render ( Jackson . json ( new ErrorResponse ( "Invalid request body" , ex ) ) ) ; } catch ( Exception e ) { ctx . getResponse ( ) . status ( Status . BAD_REQUEST ) ; ctx . render ( Jackson . json ( new ErrorResponse ( "Resolution failed" , e ) ) ) ; } }
Extracts the DID to be resolved from the request body.
Extracts the DID to be resolved from the request body .