Categorygithub.com/jackstockley89/golangwebpage
modulepackage
0.0.0-20240215102916-1e2ac964828d
Repository: https://github.com/jackstockley89/golangwebpage.git
Documentation: pkg.go.dev

# README

golangwebpage

Overview

Example of a web server created using GO, running from a Docker container

How to Run in Docker Container

From repository firstly have to build the image using the following

docker build -t "cycling-blog" .

Once the image has completed building, this is now ready to run

docker run -d -p 8080:8080 cycling-blog:latest

# Functions

ActivitiesHandler Page uses the DbConnect function to connect to the backend database Once connected this function will run a query against the database pushing results to a variable The variables will save these results to the Ride struct.
DbConnect uses variable to load values from .env file and then pass them in connection parameters via a struct.
HomeHandler Page uses the Welcome struct to post welcome message and time on page loading.

# Variables

DB variable set in the main function to set the parameters used by query in RideHandler function to return correct data.

# Structs

ENV struct values used for Database Connection Handler function.
IDHandler set sql query for RideHandler function this is set by the variable below.
Ride table query list used by Activites and Ride Handler functions.
Welcome sets home page data types.