Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for some Foxx controller features #1040

Closed
myguidingstar-zz opened this issue Oct 9, 2014 · 16 comments
Closed

Docs for some Foxx controller features #1040

myguidingstar-zz opened this issue Oct 9, 2014 · 16 comments
Assignees
Milestone

Comments

@myguidingstar-zz
Copy link

I see this in Changlog for 2.2.3

  • added around for Foxx controller

but can't find the doc for that anywhere

Also, I can't find doc for the next argument which is used in https://github.com/triAGENS/ArangoDB/blob/master/js/server/modules/org/arangodb/foxx/format_middleware.js#L39

@13abylon 13abylon self-assigned this Oct 9, 2014
@moonglum moonglum added the 3 Foxx label Oct 9, 2014
@moonglum
Copy link

moonglum commented Oct 9, 2014

@pluma Could you check together with @13abylon ?

@myguidingstar-zz
Copy link
Author

It turns out that the doc for around can be found here https://github.com/triAGENS/ArangoDB/blob/master/js/server/modules/org/arangodb/foxx/controller.js#L410 and the official online doc, too. But it's missing in the ePub build.

@13abylon
Copy link

13abylon commented Oct 9, 2014

The doc for around is now also in the online documentation (http://docs.arangodb.org/Foxx/FoxxController.html#around).

@myguidingstar-zz
Copy link
Author

Hi @13abylon , I'm not sure if this "return false" feature is implemented yet. Can you check the doc for that,too? #1023


Edited: I was looking at master branch instead of devel. It is documented. Sorry for this

@13abylon
Copy link

13abylon commented Oct 9, 2014

Great :)
So can I close this issue or do you have another question regarding the documentation?

@myguidingstar-zz
Copy link
Author

well, about doc for around, it's not clear to see why manually call next() is necessary (hence the difference between before and around). I think another example for around's use case in comparision with before should be great. And does around react to "return false" as in before? What does the third argument opts do?
Btw, there's a typo in the 5th line at "a next funcion ..."

@pluma
Copy link
Contributor

pluma commented Oct 10, 2014

It's rather simple, really:

  • before is executed before the route handler is called, returning false terminates the route handling.
  • after is executed after the route handler is called.
  • around is executed instead of the route handler, the route handler is passed in as the next callback.

So you could use around for things which would otherwise be a bit difficult, e.g. timing requests:

.around(function (req, res, opts, next) {
  var start = Date.now();
  next();
  var end = Date.now();
  var delta = end - start;
  console.log('Request took', delta, 'milliseconds to complete.');
})

@myguidingstar-zz
Copy link
Author

@pluma the current doc says around accept four arguments:

(req, res, opts, next)

is it correct?

@pluma
Copy link
Contributor

pluma commented Oct 10, 2014

@myguidingstar Yes, sorry, I fixed the example.

@myguidingstar-zz
Copy link
Author

then what does opts do, @pluma ?

@pluma
Copy link
Contributor

pluma commented Oct 10, 2014

@fceller I think you know the router internals better than me?

@13abylon 13abylon assigned fceller and unassigned 13abylon Oct 14, 2014
@13abylon
Copy link

The typo is fixed, now only @fceller needs to answer the question

@myguidingstar-zz
Copy link
Author

An other doc issue here. In module "console" it says:

console.groupCollapsed
console.groupCollapsed(format, argument1, ...)
Same as console.group, but with the group initially collapsed.

But what does "collapsed" mean here anyway?

@fceller fceller added this to the 2.4 Christmas Release milestone Dec 2, 2014
@razvanphp
Copy link

I found other 2 (summary and notes):
https://github.com/arangodb/arango-cms/blob/master/cms.js#L29

@moonglum
Copy link

summary and notes are internal 😄

@pluma
Copy link
Contributor

pluma commented Mar 25, 2015

@moonglum is it? The docs mention the auto-magical summary comments, though. See https://docs.arangodb.com/Foxx/Develop/Controller.html

@pluma pluma modified the milestones: 2.6, 2.4 May 6, 2015
@pluma pluma assigned pluma and unassigned fceller May 6, 2015
@pluma pluma closed this as completed in 4a3bd98 May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants