Liking cljdoc? Tell your friends :D

cider.nrepl.middleware.content-type

Rich content handling for CIDER. Mostly derived from the pprint middleware.


In the long ago, @technomancy [1] talked about his vision for using nREPL to support multimedia results beyond plain text, ala DrRacket and other "rich" REPLs. There was an initial cut at this [2], which never became part of the mainline Emacs tooling.

The goal of this module is to provide some support for recognizing multimedia objects (images and URIs thereto) as the result of evaluation, so that they can be rendered by a REPL.

The design of this module is based heavily on RFC-2045 [3] which describes messages packaged with Content-Type, Content-Transfer-Encoding and of course a body in that it seeks to provide decorated responses which contain metadata which a client can use to provide a rich interpretation.

There's also RFC-2017 [4] which defines the message/external-body MIME type for defining messages which don't contain their own bodies.

The basic architecture of this changeset is that eval results are inspected, and matched against two fundamental supported cases. One is that the value is actually a binary Java image, which can be MIME encoded and transmitted back directly. The other is that the object is some variant of a URI (such as a file naming an image or other content) which cannot be directly serialized. In this second case we send an RFC-2017 response which provides the URL from which a client could request the nREPL server slurp the desired content.

Hence the slurp middleware which slurps URLs and produces MIME coded data.


[1] https://groups.google.com/forum/#!topic/clojure-tools/rkmJ-5086RY [2] https://github.com/technomancy/nrepl-discover/blob/master/src/nrepl/discover/samples.clj#L135 [3] https://tools.ietf.org/html/rfc2045 [4] https://tools.ietf.org/html/rfc2017

Rich content handling for CIDER.
Mostly derived from the pprint middleware.

---

In the long ago, @technomancy [1] talked about his vision for using
nREPL to support multimedia results beyond plain text, ala DrRacket
and other "rich" REPLs. There was an initial cut at this [2],
which never became part of the mainline Emacs tooling.

The goal of this module is to provide some support for recognizing
multimedia objects (images and URIs thereto) as the result of
evaluation, so that they can be rendered by a REPL.

The design of this module is based heavily on RFC-2045 [3] which
describes messages packaged with `Content-Type`,
`Content-Transfer-Encoding` and of course a body in that it seeks to
provide decorated responses which contain metadata which a client
can use to provide a rich interpretation.

There's also RFC-2017 [4] which defines the `message/external-body`
MIME type for defining messages which don't contain their own
bodies.

The basic architecture of this changeset is that eval results are
inspected, and matched against two fundamental supported cases. One
is that the value is actually a binary Java image, which can be MIME
encoded and transmitted back directly. The other is that the object
is some variant of a URI (such as a file naming an image or other
content) which cannot be directly serialized. In this second case we
send an RFC-2017 response which provides the URL from which a client
could request the nREPL server slurp the desired content.

Hence the slurp middleware which slurps URLs and produces MIME coded
data.

---

[1] https://groups.google.com/forum/#!topic/clojure-tools/rkmJ-5086RY
[2] https://github.com/technomancy/nrepl-discover/blob/master/src/nrepl/discover/samples.clj#L135
[3] https://tools.ietf.org/html/rfc2045
[4] https://tools.ietf.org/html/rfc2017
raw docstring

content-type-transportclj

(content-type-transport transport)

Transport proxy which allows this middleware to intercept responses and inspect / alter them.

Transport proxy which allows this middleware to intercept responses
and inspect / alter them.
sourceraw docstring

handle-content-typeclj

(handle-content-type handler msg)

Handler for inspecting the results of the eval op, attempting to detect content types and generate richer responses when content information is available.

Requires that the user opt-in by providing the content-type key in nREPL requests, same as the pprint middleware.

Note that this middleware makes no attempt to prevent pretty-printing of the eval result, which could lead to double output in some REPL clients.

Handler for inspecting the results of the `eval` op, attempting to
detect content types and generate richer responses when content
information is available.

Requires that the user opt-in by providing the `content-type` key in
nREPL requests, same as the pprint middleware.

Note that this middleware makes no attempt to prevent
pretty-printing of the eval result, which could lead to double
output in some REPL clients.
sourceraw docstring

response+content-typeclj

(response+content-type {:keys [session value] :as response})

Consumes an nREPL response, having a :value. If the :value is recognized as an AWT Image, a File, or a File URI, rewrite the response to have a :content-type being a MIME type of the content, and a :body to re-use the RFC term for the message payload.

Consumes an nREPL response, having a `:value`. If the `:value` is
recognized as an AWT Image, a File, or a File URI, rewrite the
response to have a `:content-type` being a MIME type of the content,
and a `:body` to re-use the RFC term for the message payload.
sourceraw docstring

URLCoercablecljprotocol

as-urlclj

(as-url o)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close