Set up Go module and project structure

- Populated .gitignore with Go-specific patterns
- Created placeholder Go files with basic package structure:
  - bookstack.go: Client and Config setup
  - types.go: Data structures (Book, Page, Chapter, Shelf, SearchResult)
  - errors.go: Error handling types with sentinel errors
  - http.go: HTTP helper placeholder with ListOptions
  - books.go, pages.go, chapters.go, shelves.go, search.go: Service placeholders
- Verified build succeeds with go build ./...
- No external dependencies added (stdlib only)

All files compile successfully and follow flat package structure.
This commit is contained in:
Oliver Jakoubek 2026-01-30 09:36:58 +01:00
commit 62e299192d
12 changed files with 457 additions and 0 deletions

63
bookstack.go Normal file
View file

@ -0,0 +1,63 @@
package bookstack
import (
"net/http"
"time"
)
// Config holds configuration for the Bookstack API client.
type Config struct {
// BaseURL is the base URL of the Bookstack instance (e.g., "https://docs.example.com")
BaseURL string
// TokenID is the Bookstack API token ID
TokenID string
// TokenSecret is the Bookstack API token secret
TokenSecret string
// HTTPClient is the HTTP client to use for requests.
// If nil, a default client with 30s timeout will be used.
HTTPClient *http.Client
}
// Client is the main Bookstack API client.
type Client struct {
baseURL string
tokenID string
tokenSecret string
httpClient *http.Client
// Service instances
Books *BooksService
Pages *PagesService
Chapters *ChaptersService
Shelves *ShelvesService
Search *SearchService
}
// NewClient creates a new Bookstack API client.
func NewClient(cfg Config) *Client {
httpClient := cfg.HTTPClient
if httpClient == nil {
httpClient = &http.Client{
Timeout: 30 * time.Second,
}
}
c := &Client{
baseURL: cfg.BaseURL,
tokenID: cfg.TokenID,
tokenSecret: cfg.TokenSecret,
httpClient: httpClient,
}
// Initialize services
c.Books = &BooksService{client: c}
c.Pages = &PagesService{client: c}
c.Chapters = &ChaptersService{client: c}
c.Shelves = &ShelvesService{client: c}
c.Search = &SearchService{client: c}
return c
}