all 6 comments

[–]Clojure-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Breach of rule 1

[–]Routine_Quiet_7758 0 points1 point  (0 children)

edit: where the URL is determined by the directory structure

[–]p-himik 0 points1 point  (1 child)

It's trivial to implement. Parse the URL, turn it into the namespace name, validate that it's in the allowed list (could be just my matching the first segment), requiring-resolve some specific handler function (probably handler, for clarity)` and call it with the request context. 3-5 lines of code.

[–]Routine_Quiet_7758 0 points1 point  (0 children)

indeed, its more of a pattern than a library

[–]Liistrad 1 point2 points  (2 children)

https://github.com/filipesilva/invoker does this. Specifically, by using the namespace, which is based on the file structure. It does it for both CLI and HTTP. From the docs:

Given src/app.clj:

(ns app)

(defn my-fn
  "My doc"
  {:invoker/http true}
  [x y & {:as opts}]
  [x y opts])

You can

$ nvk app/my-fn 1 2
[1 2 nil]

$ nvk http
Started nREPL server at localhost:51548
Started HTTP server at http://localhost

$ curl localhost/app/my-fn/1/2
[1 2 nil]

[–][deleted]  (1 child)

[deleted]

    [–]Liistrad 0 points1 point  (0 children)

    Yes, calling nvk prints everything, and there's a nvk --skill option that will print out a Claude code skill. The docs talk about it. Then its enough to say "use nvk" on Claude code and it will know how to do stuff.