Documentation
¶
Index ¶
- func FetchFeed(feedURL string) (*models.RSSFeed, error)
- func HandlerErr(w http.ResponseWriter, r *http.Request)
- func HandlerReadiness(w http.ResponseWriter, r *http.Request)
- func HashPassword(password string) ([]byte, error)
- func ParsePubDate(pubDate string) (sql.NullTime, error)
- func RespondWithError(w http.ResponseWriter, code int, msg string)
- func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
- func ScrapeFeed(db *database.Queries, wg *sync.WaitGroup, feed database.Feed)
- func StartScraping(db *database.Queries, concurrency int, timeBetweenRequest time.Duration)
- func VerifyPassword(hashedPassword string, providedPassword string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchFeed ¶
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 ¶
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 ¶
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 ¶
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 ¶
StartScraping initiates a periodic feed scraping process. It fetches feeds every `timeBetweenRequest` duration using `concurrency` number of goroutines.
func VerifyPassword ¶
VerifyPassword compares a hashed password with a provided password to check if they match.
Types ¶
This section is empty.