package com.kapdion.omds.productdefinitions;

import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class HydraHeaderFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        HttpServletResponse httpServletResponse = (HttpServletResponse) response;

        // Der Link zeigt auf dein Vocab-File
        String linkHeader = "<http://localhost:9090/produktwissen-app/produktApi/vocab.jsonld>; rel=\"http://www.w3.org/ns/hydra/core#apiDocumentation\"";
        httpServletResponse.setHeader("Link", linkHeader);

        chain.doFilter(request, response);
    }
}