shiftr

command module
v0.0.0-...-9dae437 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

README

shiftr

A coding challenge to demonstrate my knowledge with Go, REST, Patterns, and Databases

Running

go get and build! It defaults to using Sqlite in-memory database, some demo data has been added in main.go

There is a postman collection file added for testing the endpoints.

First use the Login as Admin request in Postman, then List Users. That will set up the environment variables for the subsequent requests.

Build Dependencies

Requires GCC to build the sqlite dependency of GORM

If running on Windows, install tdm-gcc or equivalent so that there's a GCC binary in your %PATH%

Customizaton

You can customize/configure the application with the provided configuration functions passed to server.NewConfig()

package main

import (
	"github.com/btnmasher/shiftr/server"
	"log"
)

func main() {
	cfg := server.NewConfig(
                server.ListenAddr("localhost"),
                server.ListenPort(8080),
                server.WithJWTSecret("a strong secret here!"),
                server.DatabaseDriver(server.Postgres),
                server.DatabaseHost("localhost"),
                server.DatabasePort(5432),
                server.DatabaseUser("postgres_user"),
                server.DatabasePass("postgres_password"),
                server.DatabaseName("shiftr"),
                server.WithReadTimeout(time.Second * 5),
                server.WithWriteTimeout(time.Second * 5),
                server.DebugEnabled(true),
	)

	srv := server.New()

	err := srv.Initialize(cfg)
	if err != nil {
		log.Fatalln(err)
	}

	srv.Run()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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