untangled

NEW CHANNEL: #fulcro
mitchelkuijpers 2016-11-08T08:01:27.003985Z

That would fix it πŸ™‚ @tony.kay I also found some bugs with regard to ident loading with load, Ill try to reproduce them this week

tony.kay 2016-11-08T18:05:29.004002Z

@mitchelkuijpers interesting. Let me know. Thanks

wilkerlucio 2016-11-08T19:33:05.004004Z

in untangled-server, how can I add ring session or any kind of handler wrappers?

adambros 2016-11-08T19:35:29.004005Z

I and tony added untangled-system to the latest snapshot, but I dont think it has any/good documentation Otherwise: make-untangled-server takes :components that can depend on :handler and inject into handler stack at two locations pre-hook and fallback-hook using get-pre-hook and set-pre-hook

adambros 2016-11-08T19:36:20.004009Z

let me find you a cookbook or something

wilkerlucio 2016-11-08T19:36:48.004010Z

@adambros thanks, I just figured out, found an example using the wrap-cookie, all good πŸ™‚

adambros 2016-11-08T19:37:11.004012Z

is that yours?

wilkerlucio 2016-11-08T19:37:22.004013Z

no, it came on the template from Tony

adambros 2016-11-08T19:37:28.004014Z

ah ok

wilkerlucio 2016-11-08T19:37:29.004015Z

I just added the wrap-session bit

adambros 2016-11-08T19:37:56.004016Z

in the future untangled-system is the way forwards it simply lets you have complete control over the handler stack

adambros 2016-11-08T19:38:41.004017Z

and you can create a webserver, or grab the pieces you need and put them in some other servlet

adambros 2016-11-08T19:40:00.004019Z

for now the best documentation is the specs for it

wilkerlucio 2016-11-08T19:40:11.004020Z

cool, thanks for letting me know

wilkerlucio 2016-11-08T19:40:57.004021Z

one other question, how do you set the session values? I see at the docs that I should return the ring request with the session modified from a handler, but how can we do that from a parser mutation?

adambros 2016-11-08T19:41:32.004022Z

iirc we have an open issue about that

adambros 2016-11-08T19:42:19.004025Z

you should add that you might want to change the :session

wilkerlucio 2016-11-08T19:43:15.004026Z

yeah, I guess @tony.kay is thinking on the request in general, but I'll add a note just in case

wilkerlucio 2016-11-08T19:45:29.004027Z

@tony.kay on the issue you suggest using metadata to get the response modifications, why not just a key in the response map (like untangled.server/response)?

wilkerlucio 2016-11-08T19:46:48.004028Z

oh, I see, it all get's returned to the om parser, gotcha

tony.kay 2016-11-08T21:29:56.004030Z

@wilkerlucio At the moment you can return a response to the client and use cljs to set a cookie, but we do need a general purpose solution from a mutation

tony.kay 2016-11-08T21:30:16.004031Z

but with ring-session you can access the session store

wilkerlucio 2016-11-08T21:30:33.004032Z

@tony.kay I sent a PR with a possible solution to the response problem

tony.kay 2016-11-08T21:30:38.004033Z

great

wilkerlucio 2016-11-08T21:31:01.004034Z

I first tried using the idea of meta-data returning, but since the parser can return on multiple nodes the merging could become an issue

tony.kay 2016-11-08T21:31:27.004035Z

yep, that was partly why I hadn't done it yet πŸ™‚

wilkerlucio 2016-11-08T21:31:37.004036Z

so I had another idea (a simpler one I think) that is to have a shared atom called response, that the parser can mutate, then it get's merged into the response

wilkerlucio 2016-11-08T21:31:46.004037Z

this way, the merging is user responsability

tony.kay 2016-11-08T21:31:56.004038Z

oooo..state, I dislike that more, to be honest

tony.kay 2016-11-08T21:32:21.004039Z

I'd rather have idempotent metadata...e.g. "add cookie", "add header"...things that compose well

tony.kay 2016-11-08T21:32:52.004040Z

it is /api; there isn't much you should ever need to do

tony.kay 2016-11-08T21:33:12.004041Z

and mutations are non-recursive, so it is a simple merge

wilkerlucio 2016-11-08T21:33:35.004042Z

I'm just thinking that multiple mutations can ask for example to change the session

wilkerlucio 2016-11-08T21:33:54.004043Z

in this case, if we implement the merging in untangled we are taking this decision upfront on how to manage it

tony.kay 2016-11-08T21:33:55.004044Z

changing the session should be done IN the mutation, with direct access to the session store

tony.kay 2016-11-08T21:34:01.004045Z

the only thing the client cares about is the cookie

tony.kay 2016-11-08T21:34:07.004046Z

which should be identical in both

tony.kay 2016-11-08T21:34:13.004047Z

again, idempotent

tony.kay 2016-11-08T21:34:20.004048Z

set it 5x, who cares?

tony.kay 2016-11-08T21:34:57.004049Z

Now, this IS server-side, so we don't have the app-state serialization concern

tony.kay 2016-11-08T21:35:12.004050Z

we could put a lamba on the metadata of type resp->resp

tony.kay 2016-11-08T21:35:20.004051Z

now it chains

tony.kay 2016-11-08T21:36:00.004054Z

(f (g (h response))) -> new response

wilkerlucio 2016-11-08T21:36:14.004055Z

sounds good

tony.kay 2016-11-08T21:36:30.004057Z

or rather, response

tony.kay 2016-11-08T21:36:32.004058Z

not session

wilkerlucio 2016-11-08T21:36:34.004059Z

let me update the PR, I'll revert to the metadata, and change from merging to lambds

wilkerlucio 2016-11-08T21:36:37.004060Z

yeah, response

adambros 2016-11-08T21:37:15.004063Z

now are we still limiting what you can do to the response?

tony.kay 2016-11-08T21:37:29.004064Z

no, but if you break it, it's your problem πŸ˜‰

adambros 2016-11-08T21:37:56.004065Z

is this for reads and mutates?

tony.kay 2016-11-08T21:38:01.004066Z

mutate

tony.kay 2016-11-08T21:38:14.004067Z

any reason on reads?

tony.kay 2016-11-08T21:38:38.004068Z

you have to change server state, so I'd say it only makes sense abstractly on mutations

adambros 2016-11-08T21:39:12.004069Z

makes enough sense

adambros 2016-11-08T21:41:47.004070Z

@wilkerlucio you are doing this in just reads though

wilkerlucio 2016-11-08T21:41:51.004072Z

@tony.kay updated the PR https://github.com/untangled-web/untangled-server/pull/20/files

wilkerlucio 2016-11-08T21:42:02.004074Z

the current way just doens't care if it's a read or a write

wilkerlucio 2016-11-08T21:42:07.004075Z

should we limit to writes?

adambros 2016-11-08T21:42:15.004076Z

read above tony’s last message

wilkerlucio 2016-11-08T21:42:59.004078Z

what if a user wants to change the response status from a read?

tony.kay 2016-11-08T21:43:56.004079Z

recursive parsing...how do you find them all? Throw an exception and get a 500, or return a response that you can deal with on the client. Don't care about HTTP status codes because this isn't REST

tony.kay 2016-11-08T21:44:22.004080Z

in other words, treat it more like RMI, not HTTP

wilkerlucio 2016-11-08T21:45:41.004081Z

ok, so, in this case, instead of walk the response, we can scan just the first level and apply the with-response in the ones that are symbols (and so, mutations), is that correct?

tony.kay 2016-11-08T21:46:48.004082Z

That was my take, yes. On reads, what are the use-cases where you'd need it. If there are many valid ones, then maybe we support it only on top-level values?

tony.kay 2016-11-08T21:47:15.004083Z

Headers for caching might end up being interesting when we get to http caching of responses...but I'm not sure we won't have another way of dealing with that

tony.kay 2016-11-08T21:47:34.004084Z

since you have to hook into a specific alternate URL and remote def for that

wilkerlucio 2016-11-08T21:47:55.004086Z

I don't see any case right now in favor of giving the readings, except that I also don't see a reason to don't allow it, I prefer to leave the decision of using or not to the user on those cases

tony.kay 2016-11-08T21:48:21.004087Z

So, if we only look at the shallow case, I'm ok with it handling reads and writes

wilkerlucio 2016-11-08T21:48:23.004088Z

I think allowing on the top level is a good approach until we have more input on this

tony.kay 2016-11-08T21:48:36.004089Z

agreed

tony.kay 2016-11-08T21:48:46.004090Z

can always add a filter to symbols

wilkerlucio 2016-11-08T21:49:00.004091Z

yup πŸ™‚

wilkerlucio 2016-11-08T21:56:45.004092Z

@tony.kay PR updated, scanning only root

tony.kay 2016-11-08T21:57:00.004093Z

sweet. Behavioral tests?

wilkerlucio 2016-11-08T21:57:35.004094Z

I added tests on the API method directly, there is any other place I should be checking on it?

wilkerlucio 2016-11-08T21:58:25.004095Z

also, I added a method with-response at the core, but I'm not sure if this is the best place and name for it

tony.kay 2016-11-08T21:58:40.004096Z

I'll take a look, thanks!

tony.kay 2016-11-08T21:59:51.004097Z

Hm. So, should the reduction get to see the status/body of the response? If not, then the merge order is probably wrong.

tony.kay 2016-11-08T22:00:53.004098Z

the behavioral (test) should say something like "prefers original response body and status over any appearing in the modified response"

tony.kay 2016-11-08T22:02:28.004099Z

I like the helper function. Core is a fine place for it. Naming.....suggestions anyone?

tony.kay 2016-11-08T22:02:36.004100Z

augment-response?

tony.kay 2016-11-08T22:03:00.004101Z

arg names are off, too

tony.kay 2016-11-08T22:03:23.004102Z

(defn augment-response [core-response ring-response-fn] ...)?

tony.kay 2016-11-08T22:03:33.004103Z

doc string would be extra good there

wilkerlucio 2016-11-08T22:05:28.004107Z

I though you wanted the ability to change the status, (because your example (response-with-status { :tempids {n m} } 202)), so, no body and status change, right?

tony.kay 2016-11-08T22:05:53.004108Z

ah. I'm easily swayed on that

tony.kay 2016-11-08T22:05:54.004109Z

πŸ™‚

tony.kay 2016-11-08T22:06:05.004110Z

just want a spec that says which way it is intended to behave

tony.kay 2016-11-08T22:06:14.004111Z

and proves it behaves that way

adambros 2016-11-08T22:06:45.004112Z

(augment-response {…}
   (comp
      (with-status 202)
      (with-header …)))

wilkerlucio 2016-11-08T22:06:57.004114Z

ok, I'm writing the spec for that, so I'll leave the status open and block the :body

adambros 2016-11-08T22:07:15.004115Z

it then just becomes middleware?

wilkerlucio 2016-11-08T22:07:17.004118Z

@adambros you think untangled should provide those helpers?

adambros 2016-11-08T22:07:25.004119Z

ring should have some

tony.kay 2016-11-08T22:07:29.004120Z

I'm ok being able to mess with the body, just as long as we say it is what you can do

tony.kay 2016-11-08T22:07:47.004121Z

oh right, @adambros there are already Ring response helpers like that

tony.kay 2016-11-08T22:07:52.004122Z

set-content-type etc

tony.kay 2016-11-08T22:08:14.004124Z

so yeah, just leverage the middleware helpers that are in Ring already

wilkerlucio 2016-11-08T22:08:15.004125Z

yeah, the lambda approach should enable the usage of those, nice πŸ™‚

tony.kay 2016-11-08T22:08:58.004128Z

resp -> resp

tony.kay 2016-11-08T22:09:00.004129Z

it's all good

tony.kay 2016-11-08T22:09:23.004130Z

good effort team πŸ™‚

wilkerlucio 2016-11-08T22:23:01.004131Z

@tony.kay added new specs and docs

tony.kay 2016-11-08T23:56:17.004135Z

thx. I'll look very soon.