add page for single micro-blog posts
", p.ID, p.Source, p.ID))
posted: %s
", p.Timestamp.Format("2006-01-02 15:04")))
")
", post.Title))
",
")
---
")
")
")
", post.Title))
")
")
This commit is contained in:
parent
a88994add4
commit
d6d00f6dc9
3 changed files with 76 additions and 25 deletions
|
|
@ -195,3 +195,33 @@ func (c *PocketBaseClient) GetList(
|
|||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (c *PocketBaseClient) GetRecord(
|
||||
collection string,
|
||||
id string,
|
||||
) (*[]byte, error) {
|
||||
slog.Info(
|
||||
"Getting single record from pocketbase",
|
||||
"recordId", id)
|
||||
apiURL := fmt.Sprintf("%s/api/collections/%s/records/%s", c.host, collection, id)
|
||||
resp, err := c.makeAuthenticatedRequest("GET", apiURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to make request: %w", err)
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read response body: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var res pbRes
|
||||
if err := json.Unmarshal(body, &res); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode response: %w", err)
|
||||
}
|
||||
return &body, nil
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue