...
1 package jschan
2
3 import (
4 "context"
5 "fmt"
6 "jschan/app/models"
7 "net/http"
8 )
9
10 type GetThreadOptions struct {
11 Board string
12 ThreadId int
13 }
14
15 type GetThreadResponse struct {
16 *models.Post
17 }
18
19 func (c *Client) GetThread(ctx context.Context, options *GetThreadOptions) (*GetThreadResponse, error) {
20
21 url := fmt.Sprintf("%s/%s/thread/%d.json", c.BaseURL, options.Board, options.ThreadId)
22
23 req, err := http.NewRequest(http.MethodGet, url, nil)
24 if err != nil {
25 return nil, err
26 }
27
28 req = req.WithContext(ctx)
29
30 res := GetThreadResponse{}
31 if err := c.sendRequest(req, &res, nil); err != nil {
32 return nil, err
33 }
34
35 return &res, nil
36
37 }
38
View as plain text