Java Code Examples for org.sonatype.nexus.repository.view.payloads.StringPayload

The following examples show how to use org.sonatype.nexus.repository.view.payloads.StringPayload. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Rewrites the provider JSON so that source entries are removed and dist entries are pointed back to Nexus.
 */
public Payload rewriteProviderJson(final Repository repository, final Payload payload) throws IOException {
  Map<String, Object> json = parseJson(payload);
  if (json.get(PACKAGES_KEY) instanceof Map) {
    Map<String, Object> packagesMap = (Map<String, Object>) json.get(PACKAGES_KEY);
    for (String packageName : packagesMap.keySet()) {
      Map<String, Object> packageVersions = (Map<String, Object>) packagesMap.get(packageName);
      for (String packageVersion : packageVersions.keySet()) {
        // TODO: Make this more robust, right now it makes a lot of assumptions and doesn't deal with bad things well
        Map<String, Object> versionInfo = (Map<String, Object>) packageVersions.get(packageVersion);
        versionInfo.remove(SOURCE_KEY); // TODO: For now don't allow sources, probably should make this configurable?

        Map<String, Object> distInfo = (Map<String, Object>) versionInfo.get(DIST_KEY);
        if (distInfo != null && ZIP_TYPE.equals(distInfo.get(TYPE_KEY))) {
          versionInfo.put(DIST_KEY,
              buildDistInfo(repository, packageName, packageVersion, (String) distInfo.get(REFERENCE_KEY),
                  (String) distInfo.get(SHASUM_KEY), ZIP_TYPE));
        }
      }
    }
  }
  return new StringPayload(mapper.writeValueAsString(json), payload.getContentType());
}
 
Example 2
private Content putMetadata(final Context context,
                            final Content content,
                            final AssetKind assetKind,
                            final ConanCoords coords)
    throws IOException
{
  StorageFacet storageFacet = facet(StorageFacet.class);
  try (TempBlob tempBlob = storageFacet.createTempBlob(content.openInputStream(), HASH_ALGORITHMS)) {

    if (assetKind == DOWNLOAD_URL || assetKind == DIGEST) {
      Content saveMetadata = doSaveMetadata(tempBlob, content, assetKind, coords);
      return new Content(
          new StringPayload(
              conanUrlIndexer.updateAbsoluteUrls(context, saveMetadata, getRepository()),
              ContentTypes.APPLICATION_JSON)
      );
    }
    return doSaveMetadata(tempBlob, content, assetKind, coords);
  }
}
 
Example 3
@Override
protected Response doGet(@Nonnull final Context context,
                         @Nonnull final DispatchedRepositories dispatched)
    throws Exception
{
  checkNotNull(context);
  checkNotNull(dispatched);

  Request request = context.getRequest();
  Parameters parameters = request.getParameters();
  String text = npmSearchParameterExtractor.extractText(parameters);

  NpmSearchResponse response;
  if (text.isEmpty()) {
    response = npmSearchResponseFactory.buildEmptyResponse();
  }
  else {
    response = searchMembers(context, dispatched, parameters);
  }

  String content = npmSearchResponseMapper.writeString(response);
  return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON));
}
 
Example 4
Source Project: nexus-public   Source File: NpmFacetUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void mergeDistTagResponse_multipleEntries() throws Exception {
  when(response1.getPayload()).thenReturn(new Content(
      new StringPayload("{\"latest\":\"1.0.2\",\"hello\":\"1.2.3\",\"world\":\"4.5.6\"}", APPLICATION_JSON)));
  when(response2.getPayload())
      .thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.1\",\"world\":\"5.5.5\"}", APPLICATION_JSON)));
  when(response3.getPayload())
      .thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.0\",\"hello\":\"2.2.2\"}", APPLICATION_JSON)));

  final Response mergedResponse = NpmFacetUtils
      .mergeDistTagResponse(ImmutableMap.of(repository1, response1, repository2, response2, repository3, response3));

  final byte[] content = IOUtils.toByteArray(mergedResponse.getPayload().openInputStream());
  final Map<String, String> actual = objectMapper.readValue(content, new TypeReference<Map<String, String>>() { });
  assertThat(actual.get("latest"), containsString("1.0.2"));
  assertThat(actual.get("hello"), containsString("2.2.2"));
  assertThat(actual.get("world"), containsString("5.5.5"));
}
 
Example 5
/**
 * Handle request for search.
 */
public Handler search() {
  return context -> {
    Payload payload = checkNotNull(context.getRequest().getPayload());
    try (InputStream is = payload.openInputStream()) {
      QueryBuilder query = parseSearchRequest(context.getRepository().getName(), is);
      List<PyPiSearchResult> results = new ArrayList<>();
      for (SearchHit hit : searchQueryService.browse(unrestricted(query))) {
        Map<String, Object> source = hit.getSource();
        Map<String, Object> formatAttributes = (Map<String, Object>) source.getOrDefault(
            MetadataNodeEntityAdapter.P_ATTRIBUTES, Collections.emptyMap());
        Map<String, Object> pypiAttributes = (Map<String, Object>) formatAttributes.getOrDefault(PyPiFormat.NAME,
            Collections.emptyMap());
        String name = Strings.nullToEmpty((String) pypiAttributes.get(PyPiAttributes.P_NAME));
        String version = Strings.nullToEmpty((String) pypiAttributes.get(PyPiAttributes.P_VERSION));
        String summary = Strings.nullToEmpty((String) pypiAttributes.get(PyPiAttributes.P_SUMMARY));
        results.add(new PyPiSearchResult(name, version, summary));
      }
      String response = buildSearchResponse(results);
      return HttpResponses.ok(new StringPayload(response, ContentTypes.APPLICATION_XML));
    }
  };
}
 
Example 6
Source Project: nexus-public   Source File: MavenUploadHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private String generatePom(final Repository repository,
                           final String basePath,
                           final String groupId,
                           final String artifactId,
                           final String version,
                           @Nullable final String packaging)
    throws IOException
{
  log.debug("Generating pom for {} {} {} with packaging {}", groupId, artifactId, version, packaging);

  String pom = mavenPomGenerator.generatePom(groupId, artifactId, version, packaging);

  MavenPath mavenPath = parser.parsePath(basePath + ".pom");

  storeAssetContent(repository, mavenPath, new StringPayload(pom, "text/xml"));

  return mavenPath.getPath();
}
 
Example 7
Source Project: nexus-public   Source File: OrientMetadataUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Writes passed in metadata as XML.
 */
public static void write(final Repository repository, final MavenPath mavenPath, final Metadata metadata)
    throws IOException
{
  MavenFacet mavenFacet = repository.facet(MavenFacet.class);
  final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  MavenModels.writeMetadata(buffer, metadata);
  mavenFacet.put(mavenPath, new BytesPayload(buffer.toByteArray(),
      MavenMimeRulesSource.METADATA_TYPE));
  final Map<HashAlgorithm, HashCode> hashCodes = mavenFacet.get(mavenPath).getAttributes()
      .require(Content.CONTENT_HASH_CODES_MAP, Content.T_CONTENT_HASH_CODES_MAP);
  checkState(hashCodes != null, "hashCodes");
  for (HashType hashType : HashType.values()) {
    MavenPath checksumPath = mavenPath.hash(hashType);
    HashCode hashCode = hashCodes.get(hashType.getHashAlgorithm());
    checkState(hashCode != null, "hashCode: type=%s", hashType);
    mavenFacet.put(checksumPath, new StringPayload(hashCode.toString(), Constants.CHECKSUM_CONTENT_TYPE));
  }
}
 
Example 8
Source Project: nexus-public   Source File: MetadataUpdaterTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateWithExisting() throws IOException {
  when(mavenFacet.get(mavenPath)).thenReturn(
      new Content(
          new StringPayload("<?xml version=\"1.0\" encoding=\"UTF-8\"?><metadata><groupId>group</groupId></metadata>",
              "text/xml")), content);
  UnitOfWork.beginBatch(tx);
  try {
    testSubject.update(mavenPath, Maven2Metadata.newGroupLevel(DateTime.now(), new ArrayList<Plugin>()));
  }
  finally {
    UnitOfWork.end();
  }
  verify(tx, times(1)).commit();
  verify(mavenFacet, times(1)).get(eq(mavenPath));
  verify(mavenFacet, times(0)).put(eq(mavenPath), any(Payload.class));
}
 
Example 9
Source Project: nexus-public   Source File: MetadataUpdaterTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void replaceWithUnchangedExisting() throws IOException {
  when(mavenFacet.get(mavenPath)).thenReturn(
      new Content(
          new StringPayload("<?xml version=\"1.0\" encoding=\"UTF-8\"?><metadata></metadata>",
              "text/xml")), content);
  UnitOfWork.beginBatch(tx);
  try {
    testSubject.replace(mavenPath, Maven2Metadata.newGroupLevel(DateTime.now(), new ArrayList<Plugin>()));
  }
  finally {
    UnitOfWork.end();
  }
  verify(tx, times(1)).commit();
  verify(mavenFacet, times(1)).get(eq(mavenPath));
  verify(mavenFacet, times(0)).put(eq(mavenPath), any(Payload.class));
}
 
Example 10
@Test
public void addContributedHandlers() throws Exception {
  final AttributesMap attributes = new AttributesMap();

  final Request request = mock(Request.class);
  final Context context = mock(Context.class);

  when(context.getRequest()).thenReturn(request);
  when(context.getAttributes()).thenReturn(attributes);
  when(context.proceed()).thenReturn(HttpResponses.ok(new Content(new StringPayload("test", "text/plain"))));

  final ContributedHandler handlerA = mock(ContributedHandler.class);
  final ContributedHandler handlerB = mock(ContributedHandler.class);
  final HandlerContributor underTest = new HandlerContributor(asList(handlerA, handlerB));
  final Response response = underTest.handle(context);

  assertThat(response.getStatus().isSuccessful(), is(true));
  assertThat(attributes.get(HandlerContributor.EXTENDED_MARKER), is(Boolean.TRUE));

  // Handle a second time to ensure the contributed handlers aren't injected twice
  underTest.handle(context);

  ArgumentCaptor<ContributedHandler> handlerCaptor = ArgumentCaptor.forClass(ContributedHandler.class);
  verify(context, times(2)).insertHandler(handlerCaptor.capture());
  assertThat(handlerCaptor.getAllValues(), is(asList(handlerB, handlerA))); // Intentionally added in "reverse" order
}
 
Example 11
/**
 * Builds a packages.json file as a {@code Content} instance containing the actual JSON for the given providers.
 */
private Content buildPackagesJson(final Repository repository, final Set<String> names) throws IOException {
  Map<String, Object> packagesJson = new LinkedHashMap<>();
  packagesJson.put(PROVIDERS_URL_KEY, repository.getUrl() + PACKAGE_JSON_PATH);
  packagesJson.put(PROVIDERS_KEY, names.stream()
      .collect(Collectors.toMap((each) -> each, (each) -> singletonMap(SHA256_KEY, null))));
  return new Content(new StringPayload(mapper.writeValueAsString(packagesJson), ContentTypes.APPLICATION_JSON));
}
 
Example 12
private void createIndexYaml() {
  ChartIndex index = new ChartIndex();
  index.setApiVersion(API_VERSION);
  index.setGenerated(new DateTime());
  Repository repository = getRepository();
  HelmContentFacet helmFacet = repository.facet(HelmContentFacet.class);
  helmFacet
      .putIndex(INDEX_YAML, new Content(new StringPayload(yamlParser.getYamlContent(index), INDEX_YAML_CONTENT_TYPE)),
          HELM_INDEX);
}
 
Example 13
@Override
public Response login(final Context context) {
  String token = conanTokenManager.login();
  if(null != token) {
    return new Response.Builder()
        .status(Status.success(OK))
        .payload(new StringPayload(token, TEXT_PLAIN))
        .build();
  }
  return badCredentials("Bad username or password");
}
 
Example 14
Source Project: nexus-public   Source File: NpmPingHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Nonnull
@Override
public Response handle(@Nonnull final Context context) throws Exception
{
  StringPayload payload = new StringPayload("{}", APPLICATION_JSON);
  return HttpResponses.ok(payload);
}
 
Example 15
Source Project: nexus-public   Source File: NpmResponses.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Nonnull
static Response npmErrorAuditResponse(
    final int statusCode,
    @Nonnull final String message)
{
  String newLineDelimiter = String.format("%s%s", lineSeparator(), DELIMITER);
  String errorMsg = String.format("%s%s%s%s", newLineDelimiter, lineSeparator(), message, newLineDelimiter);
  return new Response.Builder()
      .status(Status.failure(statusCode))
      .payload(new StringPayload(errorMsg, APPLICATION_JSON))
      .build();
}
 
Example 16
Source Project: nexus-public   Source File: NpmWhoamiHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Nonnull
@Override
public Response handle(@Nonnull final Context context) throws Exception
{
  User user = securitySystem.currentUser();

  Username username = new Username(user == null ? "anonymous" : user.getUserId());

  StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON);

  return HttpResponses.ok(payload);
}
 
Example 17
Source Project: nexus-public   Source File: NpmSearchFacetHosted.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public Content searchV1(final Parameters parameters) throws IOException {
  String text = npmSearchParameterExtractor.extractText(parameters);
  int size = npmSearchParameterExtractor.extractSize(parameters);
  int from = npmSearchParameterExtractor.extractFrom(parameters);

  // npm search V1 endpoint currently returns an empty result set if no text is provided in the request
  NpmSearchResponse response;
  if (text.isEmpty()) {
    response = npmSearchResponseFactory.buildEmptyResponse();
  }
  else {
    QueryStringQueryBuilder query = QueryBuilders.queryStringQuery(text)
        .allowLeadingWildcard(true)
        .analyzeWildcard(true);
    TermsBuilder terms = AggregationBuilders.terms("name")
        .field("assets.attributes.npm.name")
        .size(v1SearchMaxResults)
        .subAggregation(AggregationBuilders.topHits("versions")
            .addSort(SortBuilders.fieldSort("assets.attributes.npm.search_normalized_version")
                .order(SortOrder.DESC))
            .setTrackScores(true)
            .setSize(1));

    SearchResponse searchResponse = searchQueryService.search(
        repositoryQuery(query).inRepositories(getRepository()), singletonList(terms));
    Aggregations aggregations = searchResponse.getAggregations();
    Terms nameTerms = aggregations.get("name");
    response = npmSearchResponseFactory.buildResponseForResults(nameTerms.getBuckets(), size, from);
  }

  String content = npmSearchResponseMapper.writeString(response);
  return new Content(new StringPayload(content, ContentTypes.APPLICATION_JSON));
}
 
Example 18
Source Project: nexus-public   Source File: NpmAuditFacet.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private StringPayload buildResponse(
    final PackageLock packageLock,
    final ComponentsVulnerability componentsVulnerability)
{
  ResponseReport responseReport = reportCreator.buildResponseReport(componentsVulnerability, packageLock);
  String responseReportString = gson.toJson(responseReport);
  log.trace("npm audit report: {}", responseReportString);
  log.debug("Build report with metadata: {}", responseReport.getMetadata());
  return new StringPayload(responseReportString, APPLICATION_JSON);
}
 
Example 19
Source Project: nexus-public   Source File: NpmFacetUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void mergeDistTagResponse_singleEntry() throws Exception {
  when(response1.getPayload()).thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.1\"}", APPLICATION_JSON)));

  final Response mergedResponse = NpmFacetUtils
      .mergeDistTagResponse(ImmutableMap.of(repository1, response1));

  final byte[] content = IOUtils.toByteArray(mergedResponse.getPayload().openInputStream());
  final Map<String, String> actual = objectMapper.readValue(content, new TypeReference<Map<String, String>>() { });
  assertThat(actual.get("latest"), containsString("1.0.1"));
}
 
Example 20
Source Project: nexus-public   Source File: NpmFacetUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void mergeDistTagResponse_multipleEntriesSingleTag() throws Exception {
  when(response1.getPayload()).thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.0\"}", APPLICATION_JSON)));
  when(response2.getPayload()).thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.1\"}", APPLICATION_JSON)));

  final Response mergedResponse = NpmFacetUtils
      .mergeDistTagResponse(ImmutableMap.of(repository1, response1, repository2, response2));

  final byte[] content = IOUtils.toByteArray(mergedResponse.getPayload().openInputStream());
  final Map<String, String> actual = objectMapper.readValue(content, new TypeReference<Map<String, String>>() { });
  assertThat(actual.get("latest"), containsString("1.0.1"));
}
 
Example 21
Source Project: nexus-public   Source File: NpmFacetUtilsTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void mergeDistTagResponse_reverseOrder() throws Exception {
  when(response1.getPayload()).thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.1\"}", APPLICATION_JSON)));
  when(response2.getPayload()).thenReturn(new Content(new StringPayload("{\"latest\":\"1.0.0\"}", APPLICATION_JSON)));

  final Response mergedResponse = NpmFacetUtils
      .mergeDistTagResponse(ImmutableMap.of(repository1, response1, repository2, response2));

  final byte[] content = IOUtils.toByteArray(mergedResponse.getPayload().openInputStream());
  final Map<String, String> actual = objectMapper.readValue(content, new TypeReference<Map<String, String>>() { });
  assertThat(actual.get("latest"), containsString("1.0.1"));
}
 
Example 22
@TransactionalStoreBlob
protected Content storeHtmlPage(final StorageTx tx, final Asset asset, final String indexPage) throws IOException
{
  StorageFacet storageFacet = facet(StorageFacet.class);
  try (TempBlob tempBlob = storageFacet.createTempBlob(new StringPayload(indexPage, TEXT_HTML), HASH_ALGORITHMS)) {
    return saveAsset(tx, asset, tempBlob, TEXT_HTML, null);
  }
}
 
Example 23
Source Project: nexus-public   Source File: OrientPyPiGroupFacet.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Content buildMergedIndexRoot(final String name, final Supplier<String> lazyMergeResult, boolean save)
    throws IOException
{
  try {
    String html = lazyMergeResult.get();
    Content newContent = new Content(new StringPayload(html, ContentTypes.TEXT_HTML));
    return save ? saveToCache(name, newContent) : newContent;
  }
  catch (UncheckedIOException e) { // NOSONAR: unchecked wrapper, we're only interested in its cause
    throw e.getCause();
  }
}
 
Example 24
Source Project: nexus-public   Source File: ViewServlet.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
Response describe(final Request request, final Response response, final Exception exception, final String flags) {
  final Description description = new Description(ImmutableMap.<String, Object>of(
      "path", request.getPath(),
      "nexusUrl", BaseUrlHolder.get()
  ));
  if (exception != null) {
    descriptionHelper.describeException(description, exception);
  }
  descriptionHelper.describeRequest(description, request);
  if (response != null) {
    descriptionHelper.describeResponse(description, response);
  }

  DescribeType type = DescribeType.parse(flags);
  log.trace("Describe type: {}", type);
  switch (type) {
    case HTML: {
      String html = descriptionRenderer.renderHtml(description);
      return HttpResponses.ok(new StringPayload(html, ContentTypes.TEXT_HTML));
    }
    case JSON: {
      String json = descriptionRenderer.renderJson(description);
      return HttpResponses.ok(new StringPayload(json, ContentTypes.APPLICATION_JSON));
    }
    default:
      throw new RuntimeException("Invalid describe-type: " + type);
  }
}
 
Example 25
@Test
public void customStatusMessageIsMaintainedWithPayload() throws Exception {
  when(request.getAction()).thenReturn(HttpMethods.GET);

  Payload detailedReason = new StringPayload("Please authenticate and try again", "text/plain");

  Response response = new Response.Builder()
      .status(Status.failure(FORBIDDEN, "You can't see this"))
      .payload(detailedReason).build();

  underTest.send(request, response, httpServletResponse);

  verify(httpServletResponse).setStatus(403, "You can't see this");
}
 
Example 26
Source Project: nexus-public   Source File: MavenIOUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static Map<HashType, Payload> hashesToPayloads(final Map<HashAlgorithm, HashCode> hashCodes)
{
  Map<HashType, Payload> payloadByHash = new EnumMap<>(HashType.class);
  for (HashType hashType : HashType.values()) {
    HashCode hashCode = hashCodes.get(hashType.getHashAlgorithm());
    if (hashCode != null) {
      Payload payload = new StringPayload(hashCode.toString(), CHECKSUM_CONTENT_TYPE);
      payloadByHash.put(hashType, payload);
    }
  }
  return payloadByHash;
}
 
Example 27
Source Project: nexus-public   Source File: MetadataUpdaterTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateWithExistingCorrupted() throws IOException {
  when(mavenFacet.get(mavenPath)).thenReturn(
      new Content(new StringPayload("ThisIsNotAnXml", "text/xml")), content);
  UnitOfWork.beginBatch(tx);
  try {
    testSubject.update(mavenPath, Maven2Metadata.newGroupLevel(DateTime.now(), new ArrayList<Plugin>()));
  }
  finally {
    UnitOfWork.end();
  }
  verify(tx, times(1)).commit();
  verify(mavenFacet, times(2)).get(eq(mavenPath));
  verify(mavenFacet, times(1)).put(eq(mavenPath), any(Payload.class));
}
 
Example 28
Source Project: nexus-public   Source File: MetadataUpdaterTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void replaceWithExistingCorrupted() throws IOException {
  when(mavenFacet.get(mavenPath)).thenReturn(
      new Content(new StringPayload("ThisIsNotAnXml", "text/xml")), content);
  UnitOfWork.beginBatch(tx);
  try {
    testSubject.replace(mavenPath, Maven2Metadata.newGroupLevel(DateTime.now(), new ArrayList<Plugin>()));
  }
  finally {
    UnitOfWork.end();
  }
  verify(tx, times(1)).commit();
  verify(mavenFacet, times(2)).get(eq(mavenPath));
  verify(mavenFacet, times(1)).put(eq(mavenPath), any(Payload.class));
}
 
Example 29
Source Project: nexus-public   Source File: CocoapodsProxyFacet.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Content transformSpecFile(final Payload payload) throws IOException {
  try (InputStream data = payload.openInputStream()) {
    String specFile = IOUtils.toString(data, Charsets.UTF_8);
    try {
      return new Content(
          new StringPayload(specTransformer.toProxiedSpec(specFile, URI.create(getRepository().getUrl() + "/")),
              "application/json"));
    }
    catch (InvalidSpecFileException e) {
      log.info("Invalid Spec file", e);
      return null;
    }
  }
}
 
Example 30
@Nonnull
@Override
public Response handle(@Nonnull final Context context) throws Exception {
  TemplateParameters params = templateHelper.parameters();
  params.set("repository", context.getRepository());

  String html = templateHelper.render(template, params);
  return HttpResponses.ok(new StringPayload(html, "text/html"));
}