Compare commits

...

2 Commits

Author SHA1 Message Date
Felipe M f23ff3d03e
Fix README typo 2021-03-10 12:07:44 +01:00
Felipe M 1903bfe3e1
Cache also request query parameters 2021-03-10 12:07:32 +01:00
2 changed files with 5 additions and 4 deletions

View File

@ -15,18 +15,18 @@ import (
func main() {
// Retrieve manga information
manga, err := mangadex.GetManga(123)
manga, errManga := mangadex.GetManga(123)
if errManga != nil {
log.Println("Error retrieving manga: %s", errManga)
}
// Retrieve a list of chapters
// Retrieve a list of chapters
chaptersRequest := NewGetChaptersParams()
chapters, errChapterList = manga.getChapters(chaptersRequest)
if errChapterList != nil {
log.Println("Error retrieving chapters page %d: %s", chaptersRequest.Page, errChapterList)
}
// Disables chache reads for requests beyond this point
mangadex.DisableCache()

View File

@ -39,7 +39,8 @@ func getCachePath(mangadexURL *url.URL) string {
// getCacheFilename generates a cache filename based on the URL of the request
// TODO: Use query arguments as well
func getCacheFilename(mangadexURL *url.URL) string {
return strings.ReplaceAll(mangadexURL.Path, "/", "_")
filename := strings.ReplaceAll(mangadexURL.Path, "/", "_")
return filename + strings.ReplaceAll(mangadexURL.Query().Encode(), "&", "-")
}
// cacheExists checks that the cache for a certain URL exists or not