This is a simple Golang REST API boilerplate. The API provides endpoints to retrieve information about books stored in an SQLite3 database, it can serve as base project and extended further.
- Go 1.13 or later (for module support)
-
Install packages using
go get -u ./...
-
Run the application:
go run main.go
The application will be running on port 3000.
- Endpoint:
/books
- Method:
GET
- Example:
curl http://localhost:3000/books
- Endpoint:
/books/{id}
- Method:
GET
- Example:
curl http://localhost:3000/books/1
- Endpoint:
/books/{bookid}/pages/{page}/{contentFormat}
- Method:
GET
- Parameters:
{bookid}
: ID of the book{page}
: Page number{contentFormat}
: Content format (text or html)- Example:
curl http://localhost:3000/books/1/pages/3/text
An SQLite database named books.db
is provided inside the ./data
folder. It contains 5 books, each with multiple pages.
To run tests, use the following command:
go test -v ./...