Seatbelt

Build HTML web apps with Go

$ go get github.com/go-seatbelt/seatbelt

With the library installed, create a new file named main.go with the following code. This starts a server on http://localhost:3000 that responds with "Hello, world!" in plain text.

package main

import "github.com/go-seatbelt/seatbelt"

func main() {
    app := seatbelt.New()
    app.Get("/", func(c *seatbelt.Context) error {
    	return c.String(200, "Hello, world!")
	})
    app.Start(":3000")
}

With the library installed, create a new file named main.go with the following code. This starts a server on http://localhost:3000 that responds with "Hello, world!" in plain text.

package main

import "github.com/go-seatbelt/seatbelt"

func main() {
    app := seatbelt.New()
    app.Get("/", func(c *seatbelt.Context) error {
    	return c.Render("index", map[string]any{
			"Message": "Hello, world!",
		})
	})
    app.Start(":3000")
}

With the library installed, create a new file named main.go with the following code. This starts a server on http://localhost:3000 that responds with "Hello, world!" in plain text.

package main

import "github.com/go-seatbelt/seatbelt"

func main() {
	app := seatbelt.New()
	app.Get("/", func(c *seatbelt.Context) error {
		return c.Render("index", map[string]any{
			"Name": c.Session.Get("name"),
		})
	})
	app.Post("/", func(c *seatbelt.Context) error {
		c.Session.Set("name", c.FormValue("name"))
		return c.Redirect("/")
	})
	app.Start(":3000")
}