Search in sources :

Example 11 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project spring-boot by spring-projects.

the class SampleWebSecureApplication method home.

@GetMapping("/")
public String home(Map<String, Object> model) {
    model.put("message", "Hello World");
    model.put("title", "Hello Home");
    model.put("date", new Date());
    return "home";
}
Also used : Date(java.util.Date) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 12 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project cas by apereo.

the class MetricsController method handle.

/**
 * Handle.
 *
 * @param request  the request
 * @param response the response
 * @throws Exception the exception
 */
@GetMapping
public void handle(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    ensureEndpointAccessIsAuthorized(request, response);
    final MetricsServlet servlet = new MetricsServlet(this.metrics);
    servlet.init(new DelegatingServletConfig());
    servlet.service(request, response);
}
Also used : MetricsServlet(com.codahale.metrics.servlets.MetricsServlet) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 13 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project cas by apereo.

the class PersonDirectoryAttributeResolutionController method handleRequestInternal.

/**
 * Handle request.
 *
 * @param request  the request
 * @param response the response
 * @return the model and view
 */
@GetMapping
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) {
    ensureEndpointAccessIsAuthorized(request, response);
    final Map model = new LinkedHashMap();
    return new ModelAndView("monitoring/attrresolution", model);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 14 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project cas by apereo.

the class StatisticsController method handleRequestInternal.

/**
 * Handles the request.
 *
 * @param httpServletRequest  the http servlet request
 * @param httpServletResponse the http servlet response
 * @return the model and view
 */
@GetMapping
protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) {
    ensureEndpointAccessIsAuthorized(httpServletRequest, httpServletResponse);
    final ModelAndView modelAndView = new ModelAndView(MONITORING_VIEW_STATISTICS);
    modelAndView.addObject("pageTitle", modelAndView.getViewName());
    modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors());
    modelAndView.addObject("casTicketSuffix", casProperties.getHost().getName());
    modelAndView.getModel().putAll(getAvailability(httpServletRequest, httpServletResponse));
    modelAndView.addObject("startTime", this.upTimeStartDate.toLocalDateTime());
    modelAndView.getModel().putAll(getMemoryStats(httpServletRequest, httpServletResponse));
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 15 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project cas by apereo.

the class StatusController method handleRequestInternal.

/**
 * Handle request.
 *
 * @param request  the request
 * @param response the response
 * @throws Exception the exception
 */
@GetMapping
@ResponseBody
protected void handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    ensureEndpointAccessIsAuthorized(request, response);
    final StringBuilder sb = new StringBuilder();
    final Health health = this.healthEndpoint.invoke();
    final Status status = health.getStatus();
    if (status.equals(Status.DOWN) || status.equals(Status.OUT_OF_SERVICE)) {
        response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value());
    }
    sb.append("Health: ").append(status.getCode());
    sb.append("\n\nHost:\t\t").append(StringUtils.isBlank(casProperties.getHost().getName()) ? InetAddressUtils.getCasServerHostName() : casProperties.getHost().getName());
    sb.append("\nServer:\t\t").append(casProperties.getServer().getName());
    sb.append("\nVersion:\t").append(CasVersion.getVersion());
    response.setContentType(MediaType.TEXT_PLAIN_VALUE);
    try (Writer writer = response.getWriter()) {
        IOUtils.copy(new ByteArrayInputStream(sb.toString().getBytes(response.getCharacterEncoding())), writer, StandardCharsets.UTF_8);
        writer.flush();
    }
}
Also used : Status(org.springframework.boot.actuate.health.Status) HttpStatus(org.springframework.http.HttpStatus) Health(org.springframework.boot.actuate.health.Health) ByteArrayInputStream(java.io.ByteArrayInputStream) Writer(java.io.Writer) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)737 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)78 ArrayList (java.util.ArrayList)52 ModelAndView (org.springframework.web.servlet.ModelAndView)48 List (java.util.List)46 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 Map (java.util.Map)37 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)32 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 RequestParam (org.springframework.web.bind.annotation.RequestParam)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)30 HttpServletRequest (javax.servlet.http.HttpServletRequest)29 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28