medium

package
v0.0.0-...-51f6bbf Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Medium

type Medium struct {
	EnvVar *config.EnvVar
	Cache  *cache.Cache
}

Medium represents blog class

func New

func New(e *config.EnvVar, c *cache.Cache) *Medium

New instantiates new Blog

func (*Medium) Fetch

func (m *Medium) Fetch() (*Response, error)

Fetch fetches data from rss feed

func (*Medium) Handler

func (m *Medium) Handler() http.HandlerFunc

Handler handles http request and return response

type Node

type Node struct {
	Tag      string              `json:"tag"`
	Text     string              `json:"text"`
	Attrs    []map[string]string `json:"attrs"`
	Children []*Node             `json:"children"`
}

Node represents DOM element in HTML

func TokenizeHTML

func TokenizeHTML(s string) (*Node, error)

TokenizeHTML parses html string into Node struct

type Post

type Post struct {
	ID         string   `json:"id"`
	Title      string   `json:"title"`
	Link       string   `json:"link"`
	Published  string   `json:"published"`
	Author     string   `json:"author"`
	Categories []string `json:"categories"`
	Content    *Node    `json:"content"`
}

Post represents single post in blog api response body

type Response

type Response struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Link        string `json:"link"`
	Posts       []Post `json:"posts"`
}

Response represents blog api response body

func (*Response) Render

func (*Response) Render(w http.ResponseWriter, r *http.Request) error

Render renders the JSON

Jump to

Keyboard shortcuts

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