service

package module
v0.0.0-...-be6fd67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 5 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReactLinkPreview

func NewReactLinkPreview(origins []string) http.Handler

NewReactLinkPreview - create new http handler for previewing links

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL