package com.kapdion.omds.productdefinitions;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin(origins = "*", exposedHeaders = "Link")
public class EntryPointController {

    @GetMapping(value = "/", produces = "application/ld+json")
    public ResponseEntity<String> getEntryPoint() {

        String body = """
        {
          "@context": "http://localhost:9090/produktwissen-app/produktApi/context.jsonld",
          "@id": "http://localhost:9090/produktwissen-app/produktApi/",
          "@type": "hydra:EntryPoint"
        }
        """;

        return ResponseEntity.ok()
                .header(
                        "Link",
                        "<http://localhost:9090/produktwissen-app/produktApi/vocab.jsonld>; rel=\"http://www.w3.org/ns/hydra/core#apiDocumentation\""
                )
                .body(body);
    }
}