- Generates a preview for any HTTP link
- URL
- Title
- Description
- Domain
- Image URL
import io.rupj.linkpreview.models.Preview;
import io.rupj.linkpreview.service.LinkPreview;
@SpringBootApplication(scanBasePackages = "io.rupj.linkpreview")
@RestController
public class PreviewController {
private final LinkPreview preview;
PreviewController(LinkPreview preview) {
this.preview = preview;
}
@GetMapping("/preview")
public Preview preview(@RequestParam(name = "link", required = true) String link) {
return preview.generateLinkPreview(link);
}
}