Golang service for getting OpenGraph data from a URL. Useful for link previews.
The URL scheme looks like this:
https://og-service.herokuapp.com/?link=<link>
curl 'https://og-service.herokuapp.com/?link=https://v1rtl.site'
The endpoint will return data of the following structure:
{
"title": "v 1 r t l ✨",
"type": "",
"url": "v1rtl.site",
"website": "",
"description": "16 yo nullstack (TS/Go) developer, open sourcerer. Creator of go-web-app, react-postprocessing and tinyhttp. Author of t.me/we_use_js Telegram channel",
"images": []
}
The service itself is a go package that you can install and deploy on your own.
go get -u -v https://github.com/talentlessguy/og-service
And then use it in your Go HTTP server:
package main
import (
"log"
"net/http"
preview "github.com/talentlessguy/og-service"
)
func main() {
// List of origins that can request this endpoint
origins := []string{"*"}
s := preview.NewReactLinkPreviewService(origins)
log.Println("Started a service on http://localhost:8080")
// Launch the service on a port
log.Fatal(http.ListenAndServe(":8080", s))
}