Skip to content

talentlessguy/og-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

og-service

GitHub go.mod Go version go.dev reference

Golang service for getting OpenGraph data from a URL. Useful for link previews.

Instances

Usage

The URL scheme looks like this:

https://og-service.herokuapp.com/?link=<link>

Example

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": []
}

Installation

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

Using with Go

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))
}

Releases

No releases published

Packages

No packages published

Languages