Skip to content
This repository was archived by the owner on Sep 26, 2021. It is now read-only.

Feature fix: URL of index.json changed #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/tldr/remote/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/pranavraja/tldr/lib/tldr/entity"
)

const indexURL = "http://tldr.sh/assets/index.json"

func NewRemoteRepository(remote string) *Repository {
return &Repository{
remote: remote,
Expand All @@ -23,6 +25,7 @@ type Repository struct {
func (f *Repository) Page(page, platform string) (entity.Page, error) {
resp, err := http.Get(f.remote + "/" + platform + "/" + page + ".md")
if err != nil {
panic(err)
return nil, err
}
if resp.StatusCode == 404 {
Expand All @@ -37,7 +40,7 @@ func (f *Repository) Page(page, platform string) (entity.Page, error) {
}

func (f *Repository) Index() (entity.Index, error) {
resp, err := http.Get(f.remote + "/index.json")
resp, err := http.Get(indexURL)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func run() error {
if err != nil {
continue
}
defer page.Close()
fmt.Println(tldr.Render(page.Reader()))
page.Close()
return nil
}
return err
Expand Down