gofigure-go-kit

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

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 9 Imported by: 0

README

Gofigure

A minimal Go RESTful web application using Bootstrap and mux.

Build Status Go Report Card

Getting Started

  1. Be sure Go is properly installed, along with a configured $GOPATH.

  2. Set the environment variables GITHUB_USERNAMEand CONFIG_CF. For development, set CONFIG_CF=config.development and for production set CONFIG_CF=config.production. The corresponding JSON config files can be found in /._config_files/.

$ export GITHUB_USERNAME=<your_github_username>
$ export CONFIG_CF=config.development
  1. Set environment variables username, password, and database for Postgresql, and be sure to create them in postgresql as well:
$ export GOFIGURE_USERNAME=<your_postgres_username_for_database>
$ export GOFIGURE_PASSWORD=<your_password>
$ export GOFIGURE_DATABASE=<database_name>

Running

To run the application:

$ sh clean.sh
$ sh run.sh

Navigate to http://localhost:8080 and you should see the following page: alt tag

Project Structure

The main entry for the application is is main.go, where the configuration file is loaded, a database connection is created, and the application is started.

The server-side code is located in api/:

$ tree api/
api/
├── app
│   ├── app.go
│   └── app_test.go
├── config
│   ├── configuration.go
│   ├── configuration_test.go
│   ├── database.go
│   ├── directory.go
│   ├── log.go
│   └── server.go
├── handler
│   ├── handlers.go
│   └── handlers_test.go
└── model
    ├── database.go
    ├── database_test.go
    ├── message.go
    └── model.go


There is built in support for creating api endpoints:

// ./api/app/app.go
func (a *App) initializeRoutes(routeConfig *cfg.Configuration) {
	// Initialize config for handler
	handler.Initialize(routeConfig)
	// API Endpoints
	// Register your API endpoints here. E.g.:
	// api := a.Router.PathPrefix("/api/v1").Subrouter() <-- create appropriate
	// path prefix for Subrouter
	// api.Methods("GET").Path("/<dir>").HandlerFunc(<your_handler>)
	api := a.Router.PathPrefix("/api/v1").Subrouter()
	api.Methods("GET").Path("/greetings/hello/{name}").HandlerFunc(handler.GetHelloHandler)

All client-side code is located in the static/ directory:

$ tree static
static
├── css
│   └── main.css
├── img
│   └── index.png
├── index.html
├── js
└── vendor
    └── bootstrap-4.0.0

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
app

Jump to

Keyboard shortcuts

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