https://github.com/paologaleotti/blaze-api-example
Example of a REST API using Go, blaze, sqlx
https://github.com/paologaleotti/blaze-api-example
api example go http rest sql sqlx
Last synced: 7 months ago
JSON representation
Example of a REST API using Go, blaze, sqlx
- Host: GitHub
- URL: https://github.com/paologaleotti/blaze-api-example
- Owner: paologaleotti
- License: mit
- Created: 2024-07-03T18:28:52.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-11T18:02:55.000Z (over 1 year ago)
- Last Synced: 2025-03-24T01:47:30.441Z (10 months ago)
- Topics: api, example, go, http, rest, sql, sqlx
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# blaze example app
This repo contains an example of a HTTP API built using the [blaze](https://github.com/paologaleotti/blaze) template.
It features a simple CRUD API for managing todos, including:
- A basic blaze scaffolding (including logging, configuration, structure...)
- Clean structure and dependency inversion
- SQL data storage using SQLite and [sqlx](https://github.com/jmoiron/sqlx)
- Database migrations using [goose](https://github.com/pressly/goose)
- Full Prometheus metrics instrumentation (enabled by environment variable)
## Running the application
Requirements:
- Go >= 1.22
- sqlite3
- goose
Before running, export the required environment variables for the service (see `internal/api/env.go`) and for Goose (see `.env.template` for all needed env).
To run the app, first create the database and apply the migrations:
```sh
goose up
```
Then build and run the API:
```sh
make
```
```sh
./bin/api/main
```
Done! The API will be available at `http://localhost:3000`.
Prometheus metrics will be available at `http://localhost:3000/metrics`.