Skip to content

CodeIter/gowebserver

Repository files navigation

Go web server

Small example HTTP server written in Go. Serves HTML views, static assets, and a small API surface.

Quickstart

Requirements:

  • Go 1.26+

Build:

make build

Run:

make run
# or
./bin/server
# or for development
go run ./cmd/server

Configuration

This project supports .env files (loaded automatically) and a few command-line flags.

  • Environment file: copy .env.example.env and edit values.
  • Flags (highest priority):
    • -host (default 0.0.0.0)
    • -port (default 8000)
    • -resources (path served at /resources/ for large files)
    • -serve (addional path served at /)
    • -version (prints binary version)

.env variables (examples in .env.example): HOST, PORT ...

Embedded assets

views/, static/, and public/ are embedded into the binary via assets.go. The server always serves those embedded files at runtime; to change the content, edit the files under their respective folders and rebuild the binary.

Routes

  • GET / - home page (rendered with Go html/template)
  • GET /* - addional path served at / route set by -serve
  • GET /* - public assets served at / route
  • GET /static/* - static assets
  • GET /health - health check (JSON)
  • GET /ready - readiness check (JSON)
  • GET /resources/* - served from the path set by -resources
  • GET /robots.txt

Templates

Templates are located in views/ and include:

  • layout.html — base layout
  • meta.html — PWA/meta includes
  • home.html — home page content

License

MIT License

About

go lang web server

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors