**WORK IN PROGRESS** golang API client for interacting with the jschan imageboard API.
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.
 
 

37 lines
637 B

package jschan
import (
"context"
"fmt"
"jschan/app/models"
"net/http"
)
type GetThreadOptions struct {
Board string
ThreadId int
}
type GetThreadResponse struct {
*models.Post
}
func (c *Client) GetThread(ctx context.Context, options *GetThreadOptions) (*GetThreadResponse, error) {
url := fmt.Sprintf("%s/%s/thread/%d.json", c.BaseURL, options.Board, options.ThreadId)
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
res := GetThreadResponse{}
if err := c.sendRequest(req, &res, nil); err != nil {
return nil, err
}
return &res, nil
}