feat(bookstack-api-2x5): implement SearchService

Implement full-text search across all Bookstack content types with
pagination support via ListOptions. Add mock server tests.
This commit is contained in:
Oliver Jakoubek 2026-01-30 09:50:44 +01:00
commit 1a26e9035a
4 changed files with 87 additions and 10 deletions

View file

@ -1,15 +1,34 @@
package bookstack
import "context"
import (
"context"
"net/url"
"strconv"
)
// SearchService handles search operations.
type SearchService struct {
client *Client
}
// Search performs a search query across all content types.
// TODO: Implement API call to GET /api/search
// Search performs a full-text search query across all content types.
// The query parameter uses Bookstack's search syntax.
func (s *SearchService) Search(ctx context.Context, query string, opts *ListOptions) ([]SearchResult, error) {
// Placeholder for future implementation
return nil, nil
v := url.Values{}
v.Set("query", query)
if opts != nil {
if opts.Count > 0 {
v.Set("count", strconv.Itoa(opts.Count))
}
if opts.Offset > 0 {
v.Set("offset", strconv.Itoa(opts.Offset))
}
}
var resp listResponse[SearchResult]
err := s.client.do(ctx, "GET", "/api/search?"+v.Encode(), nil, &resp)
if err != nil {
return nil, err
}
return resp.Data, nil
}