ldnclj

Find us on #clojure-uk
thomas 2016-02-24T08:49:32.000126Z

morning

malcolmsparks 2016-02-24T09:24:26.000127Z

@rickmoynihan: I don't know where you heard about matching verbs before routes, strictly speaking (in HTTP) a verb has nothing to do with routing to a resource, it's interpreted by the resource itself.

2016-02-24T09:40:50.000128Z

@malcolmsparks: I think I've actually just recalled it the wrong way... IIRC somebody somewhere - possibly even you in the context of yada/liberator/bidi vs (or in combination with) compojure - mentioned that compojure gets it wrong and does it the wrong way round... and I've just misrecalled what the right way was...

2016-02-24T09:41:31.000129Z

I've just checked and indeed it looks like compojure matches the method before it matches the route.

glenjamin 2016-02-24T09:42:56.000132Z

it’s a common pattern in web frameworks, even though technically incorrect

malcolmsparks 2016-02-24T09:48:30.000133Z

@rickmoynihan: :simple_smile: that's funny

malcolmsparks 2016-02-24T09:49:01.000134Z

yeah, I've said compojure gets it wrong, and I stand by that. But actually, almost everyone else gets it wrong too.

malcolmsparks 2016-02-24T09:50:02.000135Z

Edmund:         I was under the impression that it was common maritime practice
                for a ship to have a crew.

Rum:            Opinion is divided on the subject.

Edmund:         Oh, really? [starting to get the picture]

Rum:            Yahs. All the other captains say it is; I say it isn't.

Edmund:         Oh, God; Mad as a brush.
from http://allblackadderscripts.blogspot.co.uk/2012/12/blackadder-ii-episde-3-potato.html

glenjamin 2016-02-24T09:51:49.000138Z

i suppose it depends how bothered about 405 responses you are

2016-02-24T10:06:18.000139Z

@malcolmsparks: myself included it seems! :simple_smile:

2016-02-24T10:12:18.000140Z

morning

mccraigmccraig 2016-02-24T10:14:46.000142Z

gmawn

malcolmsparks 2016-02-24T11:47:49.000143Z

@glenjamin: I think it's more the fact that a resource really ought to know which methods it supports (it's meant to reveal that in the Allow response header to an OPTIONS request). But for other reasons too - mostly it's because it's part of the http model - and reinterpreting that model seems wrong to me, even for pragmatic reasons.

glenjamin 2016-02-24T11:48:15.000144Z

this assumes you’re building a service which operates / thinks in terms of resources

glenjamin 2016-02-24T11:48:27.000145Z

which probably should be the case, but isn’t always

malcolmsparks 2016-02-24T11:49:33.000146Z

yes, i'm sympathetic to pragmatic approaches, but it seems to me that there are a ton of pragmatic libraries and not too many pure ones - over time that degrades http (at a time when we actually need many of its features more than we used to)

glenjamin 2016-02-24T11:49:53.000147Z

i don’t disagree there

glenjamin 2016-02-24T11:50:22.000148Z

Although I can’t think of many cases where a user agent would be able to react differently to a 405 vs a 404

mccraigmccraig 2016-02-24T11:52:37.000149Z

@glenjamin: as the developer of a client i would react differently to a 405 than a 404

2👍
glenjamin 2016-02-24T11:53:16.000150Z

can you give an example? aside from a different error message, I can’t think of any way to take alternative remediary action

mccraigmccraig 2016-02-24T11:55:00.000151Z

i'm not talking of an automatic reaction... just that if i see i'm getting a 405 then i know that i probably need to POST instead of GET or whatever, whereas if i see a 404 then i figure i got the url wrong. this is helpful if i'm not controlling the api

glenjamin 2016-02-24T11:55:29.000152Z

ah ok, that makes sense

minimal 2016-02-24T11:56:34.000153Z

sometimes you just want the headers but not every api supports HEAD so you have to fall back to get

2016-02-24T12:52:58.000154Z

yeah a 405 is useful for a developer to see - even without a response body saying what wen't wrong

2016-02-24T12:53:28.000155Z

so it's useful for a framework to implement that behaviour

2016-02-24T13:33:46.000156Z

a 405 might also depend upon the state of a resource. It might be something in a locked period (future or past or too close to now to do PUT/DELETE or other to)

glenjamin 2016-02-24T13:48:56.000157Z

hrm, i’d often do something like a 428 for that

glenjamin 2016-02-24T13:49:46.000158Z

or 412, not sure what the difference between those is supposed to be, reading them now

2016-02-24T14:00:04.000160Z

412 looks like it is the requesters precondition (not sure how that is communicated)

2016-02-24T14:01:29.000161Z

428 seems to be more about managing concurrent requests, whereas I'm thinking about something where there might be a time range or something beyond the clients that changes what can be done w/a resource

2016-02-24T17:33:57.000162Z

agreed - but presumably only with regards to the HTTP method tried... e.g. returning 405 "locked for writes" on a POST because the resource has writes disabled seems legit... though I guess you might need to look at using an appropriate entity header to indicate that it was just a temporary state not a permanent one?

2016-02-24T17:50:02.000163Z

rickmoynihan: I'm thinking that it might be permanent from that point, that the resource has reached some final locked state (though if it could change in the future it would be good to have a way of signalling that)