Skip to content

This project provides some working examples using Go and Hotwire Turbo.

License

Notifications You must be signed in to change notification settings

wolfeidau/hotwire-golang-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

52f154f · Mar 10, 2023

History

21 Commits
Nov 23, 2022
Nov 23, 2022
Nov 23, 2022
Nov 23, 2022
Nov 23, 2022
Jan 31, 2021
Feb 5, 2021
Jan 31, 2021
Nov 23, 2022
Feb 7, 2023
Nov 23, 2022
Nov 23, 2022
Nov 23, 2022

Repository files navigation

hotwire-golang-website

This project provides some working examples using Go the hotwire/turbo library published by basecamp. This is based on a great post about Hotwire: HTML Over The Wire by @delitescere.

Overview

This service illustrates how to use turbo to enable updates to a website using primarily service side code.

  1. Uses html/template via my helper library echo-go-templates which provides layout helpers, and embedded assets with io/fs for views.
  2. Uses echo library to simplify routing.
  3. Uses a CDN to host all css / JS libraries base.html.
  4. Uses esbuild to automatically bundle JS assets on startup using echo-esbuild-middleware to serve them.

Hotwire Turbo

In this site I have implemented:

  1. Turbo Drive
  2. Turbo Frames
  3. Turbo Streams with Server Sent Events (SSE) and WebSockets
  4. stimulus

Most of the server side logic is in hotwire.go.

Prerequisites

  • Go 1.13 or later with support for Go Modules, used to build the service.
  • Node.js 12 or later, which is only used to install our asset building dependencies.

Running

To get this project running you need to setup some certificates, in my case I use https://github.com/FiloSottile/mkcert and there is a target in the makefile.

make certs

To install node dependencies

make install

To start the service just run.

make start

For development you can use the following command, this will check for code updates and restart the service.

make watch

The service should be listening on https://hotwire.localhost:9443/

License

This application is released under Apache 2.0 license and is copyright Mark Wolfe.

About

This project provides some working examples using Go and Hotwire Turbo.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published