App-Adenosine
view release on metacpan or search on metacpan
Hacking!
Want to add some features? Fork the frioux/app-adenosine repository and
send pull requests!
A Work In Progress
Adenosine was ported to Perl from resty
<https://github.com/micha/resty> due to a number of issues
<https://github.com/micha/resty/issues>. Because adenosine is not a
simple shell function it does not use env vars as much, and so is less
"persistent" than resty when it comes to various settings. I'm
completely willing to fix this by wrapping adenosine with a small shell
function that sets various environment variables, but I'd rather get it
released with a few exciting features resty does not have. With that in
mind, patches are always welcome. Please get in touch if you'd like one
of the currently unsupported resty features to be fixed and I'll
certainly do what I can to get it working. Any part of the doc marked
with !!! is a place to look out for an imcompatibility.
Usage
source adenosine-exports [-W] [remote] # load functions into shell !!!
adenosine [-v] # prints current request URI base !!!
adenosine <remote> [OPTIONS] # sets the base request URI !!!
HEAD [path] [OPTIONS] # HEAD request
OPTIONS [path] [OPTIONS] # OPTIONS request
GET [path] [OPTIONS] # GET request
DELETE [path] [OPTIONS] # DELETE request
PUT [path] [data] [OPTIONS] # PUT request
POST [path] [data] [OPTIONS] # POST request
TRACE [path] [OPTIONS] # TRACE request
PATCH [path] [OPTIONS] # PATCH request
Options:
-Q Don't URL encode the path.
-q <query> Send query string with the path. A '?' is prepended to
<query> and concatenated onto the <path>.
-W Don't write to history file (only when sourcing script). !!!
-V Edit the input data interactively in 'vi'. (PUT and POST
requests only, with data piped to stdin.)
-v Verbose output. When used with the adenosine command itself
this prints the saved curl options along with the current
URI base. Otherwise this is passed to curl for verbose
curl output.
<curl opt> Any curl options will be passed down to curl.
Configuration, Data File Locations
Adenosine creates a few files in either your ${XDG_CONFIG_HOME} and
${XDG_DATA_HOME} directory (if your system uses the XDG directory
standard) or in the ~/.resty directory, otherwise.
Using Existing, Pre-v2.1 Configuration Files With v2.1
If you had resty installed before version 2.1 and your system uses the
XDG config directory standard and you want to continue using your
existing configuration files, please make a backup of your ~/.resty
directory and then do:
$ mkdir -p "${XDG_CONFIG_HOME}/resty" "${XDG_DATA_HOME}/resty"
$ mv ~/.resty/c "${XDG_DATA_HOME}/resty"
$ mv ~/.resty/* "${XDG_CONFIG_HOME}/resty"
Request URI Base
The request URI base is what the eventual URI to which the requests
will be made is based on. Specifically, it is a URI that may contain
the * character one or more times. The * will be replaced with the path
parameter in the OPTIONS, HEAD, GET, POST, PUT, PATCH or DELETE request
as described above.
For example:
$ adenosine 'http://127.0.0.1:8080/data*.json'
http://127.0.0.1:8080/data*.json
and then
$ GET /5
{ "the_response" : true }
would result in a `GET` request to the URI
http://127.0.0.1:8080/data/5.json.
If no * character is specified when setting the base URI, it's just
added onto the end for you automatically.
HTTPS URIs
HTTPS URIs can be used, as well. For example:
$ adenosine 'https://example.com/doit'
https://example.com/doit*
URI Base History
The URI base is saved to an rc file (${XDG_CONFIG_HOME}/resty/host or
~/.resty/host) each time it's set, and the last setting is saved in an
environment variable !!! ($_resty_host). The URI base is read from the
rc file when resty starts up, but only if the $_resty_host environment
variable is not set. In this way you can make requests to different
hosts using resty from separate terminals, and have a different URI
base for each terminal.
If you want to see what the current URI base is, just run adenosine
with no arguments. The URI base will be printed to stdout.
The Optional Path Parameter
The HTTP verbs (OPTIONS, HEAD, GET, POST, PUT, PATCH and DELETE) first
argument is always an optional URI path. This path must always start
with a / character. If the path parameter is not provided on the
command line, adenosine will just use the last path it was provided
with. This "last path" is stored in an environment variable
($_resty_path), so each terminal basically has its !!! own "last path".
URL Encoding Of Path Parameter
( run in 2.195 seconds using v1.01-cache-2.11-cpan-c966e8aa7e8 )