Skip to content

uptrace/go-treemux-realworld-example-app

Repository files navigation

Go treemux + go-pg realworld example application

CircleCI PkgGoDev

❤️ Uptrace.dev - distributed traces, logs, and errors in one place

Introduction

This project implements JSON API as specified in RealWorld spec. It was created to demonstrate how to use:

Your can find some details about design principles in the Writing REST API with Go and PostgreSQL tutorial.

Project structure

Project consists of the following packages:

  • rwe global package parses configs, establishes DB connections etc.
  • org package manages users and tokens.
  • blog package manages articles and comments.
  • app folder contains application resources such as config.
  • cmd/api runs HTTP server with JSON API.
  • cmd/migrate_db command that runs SQL migrations.

The most interesting part for go-pg users is probably article filter.

Project bootstrap

First of all you need to create a config file changing defaults as needed:

cp app/config/dev.yml.default app/config/dev.yml

Project comes with a Makefile that contains following recipes:

  • make db_reset drops existing database and creates a new one.
  • make test runs unit tests.
  • make api_test runs API tests provided by RealWorld.

After checking that tests are passing you can start API HTTP server:

go run cmd/api/*.go -env=dev

Releases

No releases published

Packages

No packages published

Languages