http-demo

command module
v0.0.0-...-ea17066 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: MIT Imports: 1 Imported by: 0

README

Yokai HTTP Demo

Go version

HTTP REST API demo application, based on the Yokai Go framework.

Overview

This demo application is a simple REST API (CRUD) to manage gophers.

It provides:

  • a Yokai application container, with the HTTP server and SQL modules to offer the gophers API
  • a MySQL container to store the gophers
  • a Jaeger container to collect the application traces
Layout

This demo application is following the recommended project layout:

  • cmd/: entry points
  • configs/: configuration files
  • db/:
    • migrations/: database migrations
    • seeds/: database seeds
  • internal/:
    • handler/: HTTP handlers
    • middleware/: HTTP middlewares
    • model/: models
    • repository/: models repositories
    • service/: services
    • bootstrap.go: bootstrap
    • register.go: dependencies registration
    • router.go: routing registration
  • templates/: HTML templates
Makefile

This demo application provides a Makefile:

make up      # start the docker compose stack
make down    # stop the docker compose stack
make logs    # stream the docker compose stack logs
make fresh   # refresh the docker compose stack
make migrate # run database migrations
make test    # run tests
make lint    # run linter

Usage

Start the application

To start the application, simply run:

make fresh

After a short moment, the application will offer:

Available endpoints

On http://localhost:8080, you can use:

Route Description Type
[GET] / Dashboard template
[GET] /gophers List all gophers REST
[POST] /gophers Create a gopher REST
[GET] /gophers/:id Get a gopher REST
[DELETE] /gophers/:id Delete a gopher REST
Authentication

This demo application provides an example authentication middleware.

You can enable authentication in the application configuration file with config.authentication.enabled=true.

If enabled, you need to provide the secret configured in config.authentication.secret as request Authorization header.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL