helper

package
v0.0.0-...-1f4ab60 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchFeed

func FetchFeed(feedURL string) (*models.RSSFeed, error)

FetchFeed retrieves and parses an RSS feed from the specified URL. It returns the parsed feed or an error if fetching or parsing fails.

func HandlerErr

func HandlerErr(w http.ResponseWriter, r *http.Request)

HandlerErr handles generic internal server errors by sending a 500 response.

func HandlerReadiness

func HandlerReadiness(w http.ResponseWriter, r *http.Request)

HandlerReadiness performs a readiness check and responds with a status of "ok".

func HashPassword

func HashPassword(password string) ([]byte, error)

HashPassword hashes the provided password using bcrypt with a cost factor of 20. It returns the hashed password as a byte slice or an error if hashing fails.

func ParsePubDate

func ParsePubDate(pubDate string) (sql.NullTime, error)

ParsePubDate parses a pubDate string into a sql.NullTime, returning an error if parsing fails.

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, msg string)

RespondWithError sends an error response with the given HTTP status code and message. It also logs the error if the status code indicates a server error (5XX).

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

RespondWithJSON sends a JSON response with the given HTTP status code and payload.

func ScrapeFeed

func ScrapeFeed(db *database.Queries, wg *sync.WaitGroup, feed database.Feed)

ScrapeFeed scrapes a single feed and inserts its posts into the database. It marks the feed as fetched before processing and handles potential errors.

func StartScraping

func StartScraping(db *database.Queries, concurrency int, timeBetweenRequest time.Duration)

StartScraping initiates a periodic feed scraping process. It fetches feeds every `timeBetweenRequest` duration using `concurrency` number of goroutines.

func VerifyPassword

func VerifyPassword(hashedPassword string, providedPassword string) bool

VerifyPassword compares a hashed password with a provided password to check if they match.

Types

This section is empty.

Jump to

Keyboard shortcuts

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