https://kotlinlang.org logo
#http4k
Title
# http4k
d

DALDEI

08/03/2019, 3:28 AM
FYI: changing to stringBody() where I was using stream 'worked' fine -- Suggest some additions to the docs in this area, its non-obvious I still dont fully understand which functions are for creating a body and which are for consuming it -- the use of invoke() makes for concise code, but difficult to know what its doing or when to use what.
d

dave

08/03/2019, 6:45 AM
We can probably add something to the FAQ for this, or write something for the cookbook. As for the functions - could you elaborate? Are these the functions on Body or HttpMessage you're referring to?
d

DALDEI

08/03/2019, 6:54 PM
"functions" == the functions that get the body content. Whatever they are -- likely Im missing some This isnt well documented (in prose) so I followed examples which use the 'body' member of HttpMessage Some examples use body.stream some use stringBody() Some examples' syntax looks like a method called 'body' but I I think is the invoke method, example: Response(OK).body("Some Value") It is not at all obvious what is what --> what gets the body content vs what sets it, what is valid in a Request vs response, what functions shouldn't be called with others etc. Minimally, the 'javadocs' should have some reference to WTF these do -- or atleast which are the ones to use 'in most cases'
d

dave

08/03/2019, 7:11 PM
We can add some docs to help np. With regards to body I think it is consistent that a function without an argument is a getter and one with is a setter. Clicking through should help, but it's a good point, so we can tweak. 🙃
d

DALDEI

08/04/2019, 9:23 PM
I belive your are right that its consistant, what it isnt is 'obvious' ;)) A few comments would do a LOT of good (for the audience of people who are not-yet-http4k experts, and/or not-yet-pro+-level--kotlin-experts )
Possibly at a 'uber' level --> the example you give '*hink* it is consistent that a function without an argument is a getter and one with is a setter. ' --> <facepalm> -- in hindsight would have made it a lot easier to understand --> Particuarly if this is a globally true statement -- a 'general convention' http4k seems very heavily reliant on these kinds of conventions (which is a good thing, IMHO) --> But like gradle -- only good once you know 🙂 Maybe a second on the overall conventions could substitute for a lot of little docs on each one. Maybe there is such a section already but I missed it
In which case refrences/links to said section would do a lot of good