All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.singularity.resources.ui.UiResource Maven / Gradle / Ivy

package com.hubspot.singularity.resources.ui;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.hubspot.singularity.Singularity;
import com.hubspot.singularity.config.IndexViewConfiguration;
import com.hubspot.singularity.resources.SingularityServiceUIModule;
import com.hubspot.singularity.views.IndexView;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * Serves as the base for the UI, returns the mustache view for the actual GUI.
 */
@Singleton
@Path(UiResource.UI_RESOURCE_LOCATION + "{uiPath:.*}")
public class UiResource {
  public static final String UI_RESOURCE_LOCATION = "/ui/";

  private final IndexViewConfiguration configuration;
  private final String singularityUriBase;
  private final ObjectMapper mapper;

  @Inject
  public UiResource(
    @Named(SingularityServiceUIModule.SINGULARITY_URI_BASE) String singularityUriBase,
    IndexViewConfiguration configuration,
    @Singularity ObjectMapper mapper
  ) {
    this.configuration = configuration;
    this.singularityUriBase = singularityUriBase;
    this.mapper = mapper;
  }

  @GET
  @Produces(MediaType.TEXT_HTML)
  public IndexView getIndex() {
    return new IndexView(singularityUriBase, UI_RESOURCE_LOCATION, configuration, mapper);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy