You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
616 B
36 lines
616 B
package jschan
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"jschan/app/models"
|
|
"net/http"
|
|
)
|
|
|
|
type GetCatalogOptions struct {
|
|
Board string
|
|
}
|
|
|
|
type CatalogResponse []models.Post
|
|
|
|
func (c *Client) GetCatalog(ctx context.Context, options *GetCatalogOptions) (CatalogResponse, error) {
|
|
|
|
url := fmt.Sprintf("%s/%s/catalog.json", c.BaseURL, options.Board)
|
|
|
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req = req.WithContext(ctx)
|
|
|
|
res := CatalogResponse{}
|
|
if err := c.sendRequest(req, &res, nil); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
//TODO: GetIndex, GetLogs, etc
|
|
|