github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/httpclient/get_doc.yaml (about)

     1  - DocumentID: get
     2    Title: >+
     3      `get`
     4    CategoryID: commands
     5    Summary: >-
     6      Makes a standard HTTP request and returns the result as a JSON object
     7    Description: |-
     8      Fetches a page from a URL via HTTP/S GET request
     9    Usage: |-
    10      ```
    11      get url -> <stdout>
    12  
    13      <stdin> -> get url -> <stdout>
    14      ```
    15    Examples: |-
    16      ```
    17      ยป get google.com -> [ Status ]
    18      {
    19          "Code": 200,
    20          "Message": "OK"
    21      }
    22      ```
    23    Detail: |-
    24      ### JSON return
    25  
    26      `get` returns a JSON object with the following fields:
    27  
    28      ```
    29      {
    30          "Status": {
    31              "Code": integer,
    32              "Message": string,
    33          },
    34          "Headers": {
    35              string [
    36                  string...
    37              ]
    38          },
    39          "Body": string
    40      }
    41  
    42      The concept behind this is it provides and easier path for scripting eg pulling
    43      specific fields via the index, `[`, function.
    44  
    45      ### `get` as a method
    46  
    47      Running `get` as a method will transmit the contents of STDIN as part of the
    48      body of the HTTP GET request. When run as a method you have to include a second
    49      parameter specifying the Content-Type MIME.
    50  
    51      ### Configurable options
    52  
    53      `get` has a number of behavioral options which can be configured via Murex's
    54      standard `config` tool:
    55  
    56      ```
    57      config -> [ http ]
    58      ```
    59  
    60      To change a default, for example the user agent string:
    61  
    62      ```
    63      config set http user-agent "bob"
    64      get: google.com
    65      ```
    66  
    67      This enables sane, repeatable and readable defaults. Read the documents on
    68      `config` for more details about it's usage and the rational behind the command.
    69    Synonyms:
    70    Related:
    71    - post
    72    - item-index
    73    - element
    74    - getfile
    75    - config
    76  
    77  
    78  
    79  - DocumentID: getfile
    80    Title: >+
    81      `getfile`
    82    CategoryID: commands
    83    Summary: >-
    84      Makes a standard HTTP request and return the contents as Murex-aware data type
    85      for passing along Murex pipelines.
    86    Description: |-
    87      Fetches a resource from a URL - setting STDOUT data-type
    88    Usage: |-
    89      ```
    90      getfile url -> <stdout>
    91      ```
    92    Examples: |-
    93      ```
    94      getfile google.com 
    95      ```
    96    Detail: |-
    97      This simply fetches a resource (via HTTP GET request) from a URL and returns the
    98      byte stream to STDOUT. It will set STDOUT's data-type based on MIME defined in
    99      the `Content-Type` HTTP header.
   100  
   101      It is recommended that you only use this command if you're pipelining the output
   102      (eg writing to file or passing on to another function). If you just want to
   103      render the output to the terminal then use `open` which has hooks for smart
   104      terminal rendering.
   105  
   106      ### Configurable options
   107  
   108      `getfile` has a number of behavioral options which can be configured via
   109      Murex's standard `config` tool:
   110  
   111      ```
   112      config -> [ http ]
   113      ```
   114  
   115      To change a default, for example the user agent string:
   116  
   117      ```
   118      config set http user-agent "bob"
   119      getfile google.com
   120      ```
   121  
   122      This enables sane, repeatable and readable defaults. Read the documents on
   123      `config` for more details about it's usage and the rational behind the command.
   124    Synonyms:
   125    Related:
   126    - get
   127    - post
   128    - open
   129    - config