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

de.otto.edison.status.controller.GlobalModelAttributes Maven / Gradle / Ivy

There is a newer version: 3.3.3
Show newest version
package de.otto.edison.status.controller;

import de.otto.edison.configuration.EdisonApplicationProperties;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

@ControllerAdvice
public class GlobalModelAttributes {

    private final WebEndpointProperties webEndpointProperties;
    private final EdisonApplicationProperties edisonApplicationProperties;

    @Autowired
    public GlobalModelAttributes(final WebEndpointProperties  webEndpointProperties,
                                 final EdisonApplicationProperties edisonApplicationProperties) {
        this.webEndpointProperties = webEndpointProperties;
        this.edisonApplicationProperties = edisonApplicationProperties;
    }

    @ModelAttribute
    public void addAttributes(Model model) {
        model.addAttribute("webEndpointBasePath", webEndpointProperties.getBasePath());
        model.addAttribute("edisonManagementBasePath", edisonApplicationProperties.getManagement().getBasePath());
    }

    @ModelAttribute("requestURI")
    public String requestURI(final HttpServletRequest request) {
        return request.getRequestURI();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy