Add readme, badge, resolve issue with test
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
580a1c2fb0
commit
3053714678
|
@ -0,0 +1,7 @@
|
|||
LinkInfo
|
||||
--------
|
||||
|
||||
[![Build Status](https://drone.meow.tf/api/badges/tyler/linkinfo/status.svg)](https://drone.meow.tf/tyler/linkinfo)
|
||||
|
||||
An API/Library to get link information (Title, Description, etc)
|
||||
|
|
@ -16,7 +16,7 @@ func Test_detectContentType(t *testing.T) {
|
|||
contentType = contentType[:idx]
|
||||
}
|
||||
|
||||
if contentType != ContentTypeHtml {
|
||||
if contentType != contentTypeHtml {
|
||||
t.Fatal("Unexpected content type:", contentType)
|
||||
}
|
||||
}
|
||||
|
|
13
linkinfo.go
13
linkinfo.go
|
@ -10,6 +10,11 @@ type linkHandler struct {
|
|||
handler func(link string) (*LinkInfo, error)
|
||||
}
|
||||
|
||||
type LinkInfoApi struct {
|
||||
client *http.Client
|
||||
ImgurId string
|
||||
}
|
||||
|
||||
type LinkInfo struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
|
@ -20,14 +25,16 @@ type LinkInfo struct {
|
|||
}
|
||||
|
||||
var (
|
||||
Client = http.DefaultClient
|
||||
|
||||
linkHandlers = []*linkHandler{
|
||||
{hosts: []string{"youtube.com", "youtu.be"}, handler: youtubeLinkHandler},
|
||||
}
|
||||
)
|
||||
|
||||
func Retrieve(link string) (*LinkInfo, error) {
|
||||
func New() *LinkInfoApi {
|
||||
return &LinkInfoApi{}
|
||||
}
|
||||
|
||||
func (i *LinkInfoApi) Retrieve(link string) (*LinkInfo, error) {
|
||||
u, err := url.Parse(link)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue