inital commit
This commit is contained in:
@@ -22,7 +22,7 @@ type Journal struct {
|
||||
}
|
||||
|
||||
// GetJournal fetches a journal entry by its numeric ID.
|
||||
func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error) {
|
||||
func (c *Client) GetJournal(ctx context.Context, id JournalID, opts ...Option) (*Journal, error) {
|
||||
if id <= 0 {
|
||||
return nil, fmt.Errorf("fa: GetJournal: id must be > 0")
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error)
|
||||
}
|
||||
out = j
|
||||
return nil
|
||||
})
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error)
|
||||
// each [Journal] preview (full body included on FA's listing page).
|
||||
//
|
||||
// Use [ListOptions.MaxPages] to bound the crawl.
|
||||
func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions) iter.Seq2[*Journal, error] {
|
||||
func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions, reqOpts ...Option) iter.Seq2[*Journal, error] {
|
||||
return func(yield func(*Journal, error) bool) {
|
||||
page := opts.firstPage()
|
||||
pagesFetched := 0
|
||||
@@ -60,7 +60,7 @@ func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions
|
||||
err := c.fetch(ctx, urls.UserJournals(name, page), func(doc *goquery.Document) error {
|
||||
items, hasNext = parseUserJournalsPage(doc)
|
||||
return nil
|
||||
})
|
||||
}, reqOpts...)
|
||||
if err != nil {
|
||||
yield(nil, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user