Quick Start

Upgrade Guide

Upgrade an existing GoLazy application from v0.1.8 to v0.1.9.

By Guillermo Alvarez - Published - Updated

Upgrade from v0.1.8

GoLazy v0.1.9 is a coordinated framework, CLI, sample application, and website release. It focuses on richer controller responses, format negotiation, Server-Sent Events, and application-owned JavaScript modules. Each upgrade area below links to the focused guide that explains the feature in more detail.

After the framework release is published, update the framework requirement:

go get golazy.dev@v0.1.9
go mod tidy

Read Install GoLazy for the v0.1.9 install and module setup flow.

Install or update the matching CLI so lazy new selects the v0.1.9 sample application template:

go install github.com/golazy/lazy@v0.1.9
lazy --version

Read Run With lazy for the development command and Full App for the generated application layout.

Controller formats

Controller actions can negotiate response formats with Wants:

func (c *PostsController) Show(w http.ResponseWriter, r *http.Request) error {
    post, ok := c.posts.Get(r.PathValue("post_id"))
    if !ok {
        return lazycontroller.Error(http.StatusNotFound, fmt.Errorf("post not found"))
    }

    return c.Wants(lazycontroller.Formats{
        lazycontroller.HTML: func() error {
            c.Set("post", post)
            return nil
        },
        lazycontroller.JSON: func() error {
            return json.NewEncoder(w).Encode(post)
        },
    })
}

Existing HTML-only actions can stay unchanged.

Read Formats And MIME for format registration, Accept handling, suffix routes, JSON responses, and Turbo frame formats. Read Turbo Frames when a format response is intended for a Hotwire frame.

Response helpers and redirects

Use response helpers when an action needs metadata without manual rendering:

c.Status(http.StatusCreated)
c.Header().Set("Cache-Control", "no-store")
c.Set("post", post)
return nil

Use redirects when an action should send the browser elsewhere:

return c.RedirectTo("/posts/"+post.Param, http.StatusSeeOther)

Read Redirects, Metadata, And Errors for status, header, content type, layout, redirect, and expected-error behavior. Read Controller Routes when a redirect or PathFor call depends on route names.

Server-Sent Events

Use SSEStream for long-lived event streams:

stream, err := c.SSEStream()
if err != nil {
    return err
}
defer stream.Close()

return stream.JSON("message", map[string]string{"status": "ready"})

Streaming responses opt out of dynamic route ETags and buffered response rewrites.

Read Server-Sent Events for event sends, JSON events, heartbeats, source subscriptions, and Last-Event-ID replay handling.

Application JavaScript

Move app-owned browser modules into app/js:

app/js/app.js
app/js/controllers/hello_controller.js

Then run:

lazy js

lazy js writes /js/... importmap entries and generated lazyshaft assets under app/public/assets.

Read app/js Modules for application-owned modules, Stimulus And Turbo Imports for source directives, lazy js And js.toml for manifest and importmap generation, and lazy Dev Loop Integration for hot reload asset generation.

Previous guide

Use the v0.1.8 upgrade guide when upgrading from an older application first.