Forum OpenACS Q&A: Re: How to use ns_register_filter to establish a route to be served by NaviServer

I have been unable to find what to use in place of "some_call" in

ns_register_filter postauth /some-site-loc/ns-special/* some_call

to obtain the desired behavior. Owing to the fact that I do not really understand how the filters work, I tried to copy other ns_register_filter calls I could find in other places and, trying to follow your suggestions, I attempted to write a proc that called things like rp_filter and then returned filter_break which I placed in the place of "some_call" above. It did prevent the calling of any later filter but, it did not render the requested page.

I continued reading through the documentation that you referenced and found the call ns_shortcut_filter that only takes when method urlPattern as arguments. If I replace the middle call in my original post with

ns_shortcut_filter postauth * /some-site-loc/ns-special/*

It works exactly how I want!

Is this the call I should use for this purpose, or is there something better and are there any negative side effects of making this call? Like I mentioned, I do not really understand how the filters work. I have read through the request processor documentation but, have not found anything specifically related to the filters and how they work. Is there documentation somewhere that would help me get a better understanding?

Thank you very much for all of your help. I am a bit slow at times with my responses but, I really appreciate and value your help.

-Tony

Hi Tony

I can't believe I'm linking to a Philip Greenspun article from the 1990s, but I always recall this article when I work with registered filters/procs as he explained it very clearly https://philip.greenspun.com/wtr/aolserver/introduction-1.html

This is his explanation:
ns_register_proc GET /foo -- instead of looking in the file system for a file to serve, run a specified procedure whenever a user requests a URL starting with "/foo"
ns_register_filter GET /foo* -- in addition to what else the server might do in serving a request starting with "/foo", also run a specified procedure at a specified time (before or after the page is served)

I think in your case, ns_register_proc might be what you need.

Hope this helps
Brian