-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Paul Balogh <[email protected]>
- Loading branch information
Showing
8 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Getting Started with Go, Templ, HTMX, and Air...Oh my! | ||
|
||
## Installing Air | ||
- https://github.com/cosmtrek/air | ||
- As a Go module: `go install github.com/cosmtrek/air@latest` (v1.51.0 at this time) | ||
- Run `air init` to create a basic `.air.toml` configuration file | ||
- I'm adding to Makefile as `make develop` target | ||
- Updated the TOML config for `build.cmd` to trigger a database migration on each restart | ||
- Updated the TOML config for `misc.clean_on_exit=true` | ||
- From terminal, run a request as `http POST :9092/api/places name=NISC description="NISC Lake St. Louis Office" latitude:=38.7839 longitude:=90.7878` | ||
- Run `http GET :9092/api/places/1` to retrieve listing | ||
- Change a JSON attribute name for `model/place.go`, then run GET again to show changed attribute | ||
|
||
|
||
## Starting with Templ | ||
- https://github.com/a-h/templ, https://templ.guide/ | ||
- Install Templ CLI as a Go module `go install github.com/a-h/templ/cmd/templ@latest` | ||
- Add use of the CLI to `make develop` to have a watcher on templates to auto-generate Go code from templates | ||
- Update Air configuration to let Templ watch for template changes, then Air will watch for Go changes | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package views | ||
|
||
templ Index() { | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>StL Go!</title> | ||
</head> | ||
<body> | ||
Hello STLGo From Templ! | ||
</body> | ||
</html> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package views | ||
|
||
import ( | ||
"github.com/a-h/templ" | ||
"github.com/gorilla/mux" | ||
|
||
"github.com/weesvc/weesvc-gorilla/app" | ||
) | ||
|
||
// UI represents the context for the public interface. | ||
type UI struct { | ||
App *app.App | ||
//Config *Config | ||
} | ||
|
||
// New creates a new API instance. | ||
func New(a *app.App) (ui *UI) { | ||
ui = &UI{App: a} | ||
// ui.Config = initConfig() | ||
return ui | ||
} | ||
|
||
// Init is where we define the routes our API will support. | ||
func (ui *UI) Init(r *mux.Router) { | ||
//places, err := ui.App.NewContext().GetPlaces() | ||
//if err != nil { | ||
// | ||
//} | ||
|
||
r.Handle("/", templ.Handler(Index())) | ||
Check failure on line 30 in views/routes.go GitHub Actions / lint
|
||
} |