Closed andreasevers closed 9 years ago
Have you looked at using a LinkExtractor
on the response from the MockMvc
call? It gives you a Map
of links keyed by href
:
MockHttpServletResponse response = mockMvc.perform(get("/")).andReturn()
.getResponse();
LinkExtractor linkExtractor = LinkExtractors.extractorForContentType(response
.getContentType());
Map<String, List<Link>> links = linkExtractor.extractLinks(response);
You would then be free to write out the links in whatever format you need.
@andreasevers Sorry, I forgot to mention you in my comment above
Oh no problem, I'm subscribed anyway :)
I'll for sure try this out. It seems like a way easier approach than what I was using as of now.
When I'm done I'll try to showcase the eventual solution which should be pretty nice in the HAL browser.
Great, thanks. I'll look forward to the showcase.
I'm going to close this for now. If the LinkxExtractor
-based approach doesn't work out, we can re-open it and figure out an alternative.
As mentioned in my blog a couple weeks ago, I was talking with Oliver Gierke at Spring I/O about possible documentation solutions.
What would the best solution be for this approach? Parsing the generated links.adoc isn't as easy as it could be. Maybe a hook could be supported in the generation model to allow us to expose links.json on top of links.adoc.