Thank you all. After working on my architecture, I have one more
requirement.
Request | Web_Server | CLI_APP --output json | ADD_UI --output web |
ADD_HTTP_RESPONSE_MESSAGE | Web_Server > Response
It is the ADD_HTTP_RESPONSE_MESSAGE . I am using it to add HEADERS,
response code etc. This is because I want the CLI apps to be totally
independent. I do not want to add HTTP response messages to CLI_APP or
ADD_UI output so that I can reuse these tools in case I decide to make a
GUI app or mobile app or something later where HTTP is not involved. My
question is, can I give apache ADD_HTTP_RESPONSE_MESSAGE instead of writing
it on my own.
One more thing, will it be a bad idea to extend apache (ex. create a
module) to serve my purpose? Is it possible to make a module that will give
the HTTP request to `Command1 | Command2 | CommandN`, then build a
response from the output (by adding HTTP response message to it) and
then send the response back to the client.
Thanks and Best Regards,
*Ahmad Ismail*
On Thu, Jun 23, 2022 at 4:40 PM Yehuda Katz <yehuda@ymkatz.net> wrote:
> You still have a bunch of options. Some possibilities using your own code:
>
> - Your CGI script or binary called by HTTPD is a wrapper which handles the
> piping and output capture of the other program.
> - Your CGI script or binary uses the available environment variables to
> determine where it is running and outputs the appropriate format based on
> that.
>
> If you start using other modules, you could look at PHP and the `exec`
> function which can easily do what you want.
>
> - Y
>
> Sent from a device with a very small keyboard and hyperactive autocorrect.
>
> On Thu, Jun 23, 2022, 1:15 AM Ahmad Ismail <ismail783@gmail.com> wrote:
>
>> I have already bumped into CGI (after asking the question here).
>>
>> However, I have some issues with CGI. For example, I have to add HEADERS
>> maintaining CRLF etc in the output. However, I want the CLI app to be
>> totally independent. I mean, I want to output regular text or json
>> without any header. So, what I really want is:
>>
>> CLI_APP | ADD_UI | ADD_CGI_HEADER
>>
>> Where CLI_APP gives me pure json. ADD_UI adds HTML, CSS, JS on the json
>> output. And ADD_CGI_HEADER adds the extra stuff that is needed to make the
>> final response sendable via the server.
>>
>> Please note that when the user will send a request, it will have to go
>> through the total pipeline. Also please note that, I can always call ADD_UI
>> at the end of CLI_APP and call ADD_CGI_HEADER at the end of ADD_UI. But
>> that way, I am not decoupling. And the later binaries will be dependent on
>> the previous ones. This is not something I want. I want to *pipe the
>> outputs to get the final response*.
>>
>> How can I do that? Do I need to extend the apache server in any way (like
>> creating any module or something like that).
>>
>> *Thanks and Best Regards,Ahmad Ismail*
>>
>>
>> On Wed, Jun 22, 2022 at 8:52 PM Eric Covener <covener@gmail.com> wrote:
>>
>>> you can use CGI to prototype it, and FastCGI later for performance (if
>>> it matters)
>>>
>>> On Wed, Jun 22, 2022 at 10:28 AM Ahmad Ismail <ismail783@gmail.com>
>>> wrote:
>>> >
>>> > I want to create a CLI app (in this case named CLI_APP), that will
>>> > output json and can be accessed via web.
>>> >
>>> > In Linux terms, it will look like:
>>> >
>>> > Request | Web_Server | CLI_APP | ADD_UI | Web_Server > Response
>>> >
>>> > Now, I will run the app like `CLI_APP --output json`. Here, I am
>>> > saying that the CLI_APP will output json (for REST API).
>>> >
>>> > Here, `ADD_UI --output web` will add HTML, CSS, JS etc. to the JSON
>>> output.
>>> >
>>> > Can apache help me send the requests to CLI_APP via STDIN and serve
>>> > the final output of `ADD_UI --output web`?
>>> >
>>> > Thanks and Best Regards,
>>> > Ahmad Ismail
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> > For additional commands, e-mail: users-help@httpd.apache.org
>>> >
>>>
>>>
>>> --
>>> Eric Covener
>>> covener@gmail.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>>