sans-clue has asked for the wisdom of the Perl Monks concerning the following question:

I currently receive notifications from an application via snmp trap. The new version of this app only 'sends' notifications via its REST interface. I assume this would be a post type of operation. I need to create, not a full blown REST server, rather I'd like to just receive the connection and dump the payload to a file that I can parse. It really needs to be simple, because my skills are limited. Can I create a listener in Perl to do this ? I don't have the luxury of installing elaborate packages on these redhat boxes, since they exist in an internetless vacuum. Thanks

Replies are listed 'Best First'.
Re: Rest API listener (simple)
by VinsWorldcom (Prior) on Feb 01, 2017 at 21:47 UTC

    If that's the case, you probably just need a web server. There are modules that do this (HTTP::Server::Simple) but if internet access is an issue, CPAN install may be also. You could always Google "perl simple web server" and you'll find ways to code it up with IO::Socket - standard core module.

      I do have a simple webserver that has cgi capability called thttpd. I use it extensively to perform quasi rexec functions. I just wasn't sure how I would capture a webhook notification and send back an OK. Thanks

        Whatever CGI-based Perl module you are already using for your "quasi rexec functions" will have documentation on how to extract the body of a POSTed request. Refer to that for the details (or if you cannot find or understand the documentation, then reply here with specifics such as which module you are using and which version). Then it's just a matter of dumping it to a file and printing the appropriate headers and body back to the client which should be straightforward.