Giter Site home page Giter Site logo

Comments (3)

danielytics avatar danielytics commented on June 27, 2024

I guess this is because the middleware must be supplied on the nrepl server and lein repl :connect does not start a server. I tested connecting to a server started with lein repl with ultra added and the client I connected seems to pretty print just fine.

I looked at this because I'm manually embedding an nREPL server using clojure.tools.nrepl.server/start-server. You can set a custom handler using the :handler parameter and that the default handler can optionally apply middleware. So I could start my server like this:

(clojure.tools.nrepl.server/start-server
  :port 6789
  :handler (clojure.tools.nrepl.server/default-handler custom-middleware-fn))

So, my question is: is there a way for me to grammatically access ultra's nREPL middleware so that I can add it to my embedded server?

I'm not familiar with leiningen plugins, so don't know if I can just include it as a dependency and pull it out of some var or call some function to generate it.

from ultra.

venantius avatar venantius commented on June 27, 2024

You're right - I knew this at one point in time and then forgot it and subsequently created this issue 😛

Re: middleware: you can, and you actually don't need to use Ultra to do it (though you can if you like). The middleware that needs to be included server-side is the Whidbey middleware, which is what Ultra uses for pretty-printing values. The relevant blocks of code in Ultra can be found here (https://github.com/venantius/ultra/blob/master/src/ultra/repl/whidbey.clj#L7) and here (https://github.com/venantius/ultra/blob/master/src/ultra/repl.clj#L23) (side note, I hadn't looked at those namespaces in a while but there's a rather ugly circular dependency I'm working around that could easily be circumvented and which I should probably create an issue for).

Anyways, the middleware you want is is in clojure.tools.nrepl.middleware.render-values/render-values, which is a Whidbey ns (it looks like it's from clojure.tools.nrepl, but it's not). Ultra modifies the start-server function to just do a partial in case the user wants to layer additional middleware on top of that.

from ultra.

danielytics avatar danielytics commented on June 27, 2024

Thanks!

On Sun, 17 May 2015 02:03 Ursa americanus kermodei [email protected]
wrote:

Closed #29 #29.


Reply to this email directly or view it on GitHub
#29 (comment).

from ultra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.