I’ve been fortunate enough to be a CF dev for pretty much my entire IT career without having to take on using another development language so I have a knowledge hole I’d like to ask others to help me with.
I’ve built an API and I want to describe to others how to invoke it. It needs to be invoked first thing during a request before any generated content is sent back to the user. One of the possible outcomes of the API call is that the incoming user request could be aborted so that there’s no error message but also no generated content. Just a blank screen. Sending back the blank screen with no generated page code is critical.
I can tell someone using CF that it needs to be called at the beginning of the Request scope or OnRequest scope but I’m at a loss as to how to get across the same arrangement for someone using other languages/frameworks like PHP, ASP.NET, Node.js, WordPress, etc.
So, for example, for a CF based site I’d say something like: "The synchronous API call needs to be made early in the Request or OnRequest scope and BEFORE any generated page content is returned to the user". What I’m looking for is how to describe that same thing but for users of those other languages/frameworks.
Odd question but Google has been zero help (or perhaps I just don’t know how to search for something like this). Any advice/guidance would be most appreciated.
Thanks in advance!
2
Answers
Obviously, any API request must return a specific response. And probably you need to pass the expected value and the value of a certain error at the level of your API. Further, any developer will understand what information to issue when receiving some error from the API response.
You probably mean something like: "request processing is required on the server side, in case of an error, generate an empty page on the client side", etc.
It’s hard to recommend anything. Maybe
server-side rendering, SSR
Is not the answer to your question simply to tell them "It needs to be invoked first thing during a request before any generated content is sent back to the user" (I copy and pasted that from your question).
That’s it. That is absolutely clear.
That’s all you need to do.
Don’t worry about how they need to do that in their language of choice, esp given the very nature of your question, you won’t know how. It’s their job to write the code to consume your API. Not yours.
At most you could give them some usage pseudo-code along the lines of: