diff options
| author | Shulhan <ms@kilabit.info> | 2026-02-06 07:08:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-02-06 07:08:29 +0700 |
| commit | 54d395f53e344a3cf3861c0e3d2f82ad14ecc602 (patch) | |
| tree | 9f19525f8b950ddd9d715d9abe71e5545df4d65e /awwan.go | |
| parent | a3c27356bfe3e56809f579b617e02829a7ea0a68 (diff) | |
| download | awwan-54d395f53e344a3cf3861c0e3d2f82ad14ecc602.tar.xz | |
all: improve the Server-Sent Events (SSE) output
In the ExecResponse, store the event in the Output instead of message
data, so the server can iterate the Output directly and pass it to
WriteEvent directly.
The event ID now start at 1 with type "begin".
This is to minimize confusion when comparing empty Last-Event-ID from
client, which is equal to 0.
Diffstat (limited to 'awwan.go')
| -rw-r--r-- | awwan.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -389,6 +389,7 @@ func (aww *Awwan) Local(ctx context.Context, req *ExecRequest) (err error) { goto out } } + req.mlog.Flush() } req.mlog.Outf(`=== END: %s %s %s`, req.Mode, req.Script, req.LineRange) out: @@ -499,6 +500,12 @@ func (aww *Awwan) Serve(listener net.Listener, address string, isDev bool) (err return aww.httpd.start() } +// Stop the HTTP server from calling [Awwan.Serve]. +func (aww *Awwan) Stop() (err error) { + err = aww.httpd.Server.Shutdown(context.Background()) + return err +} + // loadSSHConfig load all SSH config from user's home and the awwan base // directory. func (aww *Awwan) loadSSHConfig() (err error) { |
