1
|
package eu.dnetlib;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.util.List;
|
5
|
import java.util.Set;
|
6
|
import java.util.stream.Collectors;
|
7
|
|
8
|
import javax.servlet.http.HttpServletResponse;
|
9
|
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
import org.springframework.boot.SpringApplication;
|
14
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
15
|
import org.springframework.web.bind.annotation.RequestMapping;
|
16
|
import org.springframework.web.bind.annotation.RequestMethod;
|
17
|
import org.springframework.web.bind.annotation.RestController;
|
18
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
19
|
|
20
|
@RestController
|
21
|
@SpringBootApplication
|
22
|
public class DNetOpenaireExporterApplication {
|
23
|
|
24
|
private static final Log log = LogFactory.getLog(DNetOpenaireExporterApplication.class);
|
25
|
|
26
|
@Autowired
|
27
|
private List<RequestMappingHandlerMapping> handlerMappings;
|
28
|
|
29
|
@RequestMapping(value = { "/", "/docs" })
|
30
|
public void index(final HttpServletResponse response) throws IOException {
|
31
|
response.sendRedirect("swagger-ui.html");
|
32
|
}
|
33
|
|
34
|
@RequestMapping(value = "/endpointdoc", method = RequestMethod.GET)
|
35
|
public Set<String> show() {
|
36
|
return handlerMappings.stream()
|
37
|
.map(handler -> handler.getHandlerMethods().keySet())
|
38
|
.map(rmInfo -> rmInfo.toString())
|
39
|
.collect(Collectors.toSet());
|
40
|
}
|
41
|
|
42
|
public static void main(String[] args) throws Exception {
|
43
|
SpringApplication.run(DNetOpenaireExporterApplication.class, args);
|
44
|
}
|
45
|
|
46
|
}
|