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";
}
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);
}
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);
}
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;
}
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();
}
}
Aggregations