Documentation
¶
Overview ¶
Blog: the canonical lagodev showcase.
It wires up:
- 3 models (User, Post, Comment) with foreign keys
- 3 migrations (with up + down)
- 3 factories powered by faker
- 3 seeders with explicit dependencies and a topologically-sorted runner
- 1 framework-agnostic service (PostService) plus a net/http controller that wraps it — drop the service into Gin/Fiber/Echo to compare
- A migration + seed step at startup so the binary is self-contained
Try it:
cd examples/blog
go run .
curl http://localhost:8080/posts
curl http://localhost:8080/posts/1
curl -X POST -d '{"user_id":1,"title":"Hello","slug":"hello","body":"Hi"}' http://localhost:8080/posts
Directories
¶
| Path | Synopsis |
|---|---|
|
Package controllers translates HTTP requests into PostService calls.
|
Package controllers translates HTTP requests into PostService calls. |
|
Package factories defines fake-data generators for the blog models.
|
Package factories defines fake-data generators for the blog models. |
|
Package migrations registers every migration on import.
|
Package migrations registers every migration on import. |
|
Package models holds the domain types.
|
Package models holds the domain types. |
|
Package seeders registers the blog's seeders at import time.
|
Package seeders registers the blog's seeders at import time. |
|
Package services is the framework-agnostic API surface for the blog.
|
Package services is the framework-agnostic API surface for the blog. |
Click to show internal directories.
Click to hide internal directories.