From e4fc453b141eb4ac2cb310d215f0e442029c0ff9 Mon Sep 17 00:00:00 2001 From: Johannes Edmeier Date: Fri, 13 Mar 2026 23:38:50 +0100 Subject: [PATCH] feat: support if-none-match for the extension list endpoint Use a startup timestamp as ETag for the "/" index handler so that clients can avoid re-fetching the unchanged extension list. --- CHANGELOG.md | 4 ++++ main.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2819b6..75bee8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## (next) + +- Support if-none-match for the extension list endpoint + ## v1.0.15 - Update alpine packages in Docker image to address CVEs diff --git a/main.go b/main.go index 556ee92..726109d 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,8 @@ package main import ( + "time" + _ "github.com/KimMachineGun/automemlimit" // By default, it sets `GOMEMLIMIT` to 90% of cgroup's memory limit. "github.com/rs/zerolog" "github.com/steadybit/action-kit/go/action_kit_api/v2" @@ -21,6 +23,8 @@ import ( "github.com/steadybit/extension-kit/extsignals" ) +var startedAt = time.Now().Format(time.RFC3339) + func main() { // Most Steadybit extensions leverage zerolog. To encourage persistent logging setups across extensions, // you may leverage the extlogging package to initialize zerolog. Among others, this package supports @@ -48,13 +52,13 @@ func main() { // This call registers a handler for the extension's root path. This is the path initially accessed // by the Steadybit agent to obtain the extension's capabilities. - exthttp.RegisterHttpHandler("/", exthttp.GetterAsHandler(getExtensionList)) - // This is a section you will most likely want to change: The registration of HTTP handlers // for your extension. You might want to change these because the names do not fit, or because // you do not have a need for all of them. action_kit_sdk.RegisterAction(extdebug.NewDebugAction()) + exthttp.RegisterHttpHandler("/", exthttp.IfNoneMatchHandler(func() string { return startedAt }, exthttp.GetterAsHandler(getExtensionList))) + //This will install a signal handlder, that will stop active actions when receiving a SIGURS1, SIGTERM or SIGINT extsignals.ActivateSignalHandlers()