liberator

2017-05-10T15:01:12.327932Z

I'm trying to extend liberator:

(extend-protocol Representation
  clojure.lang.PersistentHashSet
  (as-response [this context]
    {:body "asdf"}))

2017-05-10T15:01:29.337146Z

but I'm still seeing: No implementation of method: :as-response of protocol: #'liberator.representation/Representation found for class: clojure.lang.PersistentHashSet

2017-05-10T15:01:56.351301Z

I can't see what's different from the examples in liberator.representation

ordnungswidrig 2017-05-10T15:25:29.067814Z

That’s weird. Try to call as-response on an instance of HashSet directly. Does that work?

2017-05-10T16:08:01.350768Z

@ordnungswidrig no

2017-05-10T16:08:09.354585Z

(as-response #{:a 1} {:representation {:media-type "application/json"}})

2017-05-10T16:08:25.362127Z

#error {
 :cause "No implementation of method: :as-response of protocol: #'liberator.representation/Representation found for class: clojure.lang.PersistentHashSet"  

2017-05-10T16:08:26.362664Z

😞

ordnungswidrig 2017-05-10T17:01:03.768756Z

I will try to reproduce. Independent of the actual protocol that should work.

2017-05-10T17:10:31.017316Z

hmm this does appear to be [liberator "0.12.0"] not sure if this would've been fixed between versions

ordnungswidrig 2017-05-10T17:11:42.048072Z

Don't quite understand. Is it broken in 0.12 for you but ok in a different revision?

2017-05-10T17:20:27.273726Z

no was just giving context

2017-05-10T17:23:30.354133Z

hmm, it's fine with wrapping the set in a map: (as-response {:x #{:a 1}} {:representation {:media-type "application/json"}})

ordnungswidrig 2017-05-10T17:52:05.120560Z

That is a map which is supported by liberator out of the box. I suspect that somehow the extend-protocol is not executed.

ordnungswidrig 2017-05-10T19:11:56.236543Z

@owen there’s something wrong with your protocol extension. Make sure the namespace where the extension is called is required and loaded. It works for me as expected:

2017-05-10T19:13:30.274671Z

hmm odd, thanks for verifying

ordnungswidrig 2017-05-10T19:16:31.348411Z

This is on latest master but I don’t think it would make a difference on 0.12.0

ordnungswidrig 2017-05-10T19:29:14.655380Z

Tested in 0.12.0 an works locally. I’m pretty sure your call to extend-protocol is not executed.