Skip to content

I can't get a basic example to work. #18

@avilesj

Description

@avilesj

First, thank you James for all your contributions to the clojure community.

On to the problem.

I have tried to run this library before with http-kit + reitit/ring unsuccessfully. The script was not being included in the response and I gave up after spending a lot of time in it.

I recently decided to redo my approach and just go very basic, using just ring and the jetty adapter, trying to get some sort of happy path scenario.

In this new iteration, the script is in the response, it tries to make the request but it permanently stays 'pending'. Oddly enough, I do make a change in the hiccup template and the website actively refreshes, does not show the new changes in the tags (still shows the old) and the script tries to make its request, staying in a pending state.

Also for this iteration, I decided to do a very quick poc and got it generated from ChatGPT.

Code

(ns test.core
  (:require [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.refresh :refer [wrap-refresh]]
            [hiccup.page :refer [html5]]))

(defn home-page []
  (html5
   [:head
    [:title "Ring Refresh Example"]]
   [:body
    [:h1 "Welcome to the Ring-Refresh Example!"]
    [:p "This page will auto-refresh when you change the source code."]
    [:p "Try changing something and saving the file, and you'll see the update automatically."]]))

(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body (home-page)})

(def app
  (wrap-refresh handler))  ;; Wrap your handler with the `wrap-refresh` middleware

(defn -main []
  (run-jetty app {:port 3000}))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions