22 lines
455 B
Go
22 lines
455 B
Go
package site
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
datastar "github.com/starfederation/datastar/sdk/go"
|
|
)
|
|
|
|
func setupExamplesIndicator(examplesRouter chi.Router) error {
|
|
|
|
examplesRouter.Get("/fetch_indicator/greet", func(w http.ResponseWriter, r *http.Request) {
|
|
sse := datastar.NewSSE(w, r)
|
|
sse.MergeFragmentTempl(indicatorEmpty())
|
|
time.Sleep(2 * time.Second)
|
|
sse.MergeFragmentTempl(indicatorGreeting())
|
|
})
|
|
|
|
return nil
|
|
}
|