package com.kapdion.omds.productdefinitions;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin(origins = "*") // UNBEDINGT HIER AUCH HINZUFÜGEN
public class HydraDocController {

    // Lädt die Datei aus dem Classpath (kommt aus dem api-definition Modul)
    private Resource loadFile(String name) {
        return new ClassPathResource(name);
    }

    @GetMapping(value = "/context.jsonld", produces = "application/ld+json")
    public Resource getContext() {
        return loadFile("context.jsonld");
    }

    @GetMapping(value = "/vocab.jsonld", produces = "application/ld+json")
    public Resource getVocab() {
        return loadFile("vocab.jsonld");
    }
}