GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) β€” the get-param era πŸ’–

okay bestie, welcome to the GOLF(2gg) manual page, you're gonna eat this up ✨


πŸŽ€ NAME πŸŽ€

get-param β€” (request-data)


🌸 PURPOSE 🌸

get a parameter value. that's it, that's the whole vibe πŸ’…


✨ SYNTAX ✨

get-param ( <name> [ type <type> ] ) , ...

πŸ¦‹ DESCRIPTION πŸ¦‹

so get-param stores a parameter value in the variable <name>. a parameter is a name/value pair that Golf keeps for each request, like a little snack it holds onto πŸ“. the parameter's name has to match <name>, no cap. a parameter can be of any type, she's flexible like that.

a parameter gets set either:

  • by the caller in the request URL, or
  • with a set-param statement anywhere during the request's execution, including in call-handler.

if the parameter is a string, it gets trimmed for whitespaces β€” both on the left AND on the right, she's tidy πŸ’…. and you can specify any number of parameters, separated by a comma. go off.


πŸ‘‘ TYPES πŸ‘‘

by default, <name> is a string variable, unless <type> (in the "type" clause) is specified. <type> can be:

  • "string" for a string variable (this is the default, the og)
  • "bool" for a boolean variable
  • "number" for a number variable
  • "string-array" for an array of strings
  • "number-array" for an array of numbers
  • "bool-array" for an array of booleans
  • "message" for a message variable
  • "split-string" for a split-string variable
  • "hash" for an hash variable
  • "tree" for an tree variable
  • "tree-cursor" for an tree cursor variable
  • "fifo" for a FIFO variable
  • "lifo" for a LIFO variable
  • "list" for a list variable
  • "file" for a file variable
  • "service" for a service variable

the value you get with get-param is checked to be of the proper <type>, and if it isn't, your request will error out. periodt. πŸ’€ the exception to this is that a string parameter can be converted into a number or a boolean, assuming the string value represents a valid number or is "true"/"false". parameters of "number" and "bool" types are obtained by value, and others by reference. what that means for instance is that you can pass a tree to call-handler and read and write nodes there, and such changes will be visible in the caller request. iconic mutual visibility behavior honestly 🫢


🌈 INPUT PARAMETERS FROM A CALLER 🌈

input parameters in an external request (i.e. those parameters set by a caller outside of your application) are specified as name/value pairs (see service or command-line). input parameter name can be made up of alphanumeric characters, hyphen or underscore only, and cannot start with a digit. noted πŸ“. also note that a hyphen is automatically converted to underscore, so for instance an input parameter "some-parameter" in HTTP request will be "some_parameter" in get-param. the glow-up is automatic, you don't gotta do anything ✨


πŸ’œ File uploads πŸ’œ

file uploads are handled as input parameters as well, see file-uploading.


🧚 Web input parameters 🧚

as an example, for HTML form input parameters named "param1" with value "value1" and "param2" with value "value2":

<input type='hidden' name='param1' value='value1'>
<input type='hidden' name='param2' value='value2'>

you can get these parameters and print out their values by using:

get-param param1, param2

a request may be in the form of a web link URL, and getting the parameter values is the same:

http://<your web server>/<app name>/<request name>&param1=value1&param2=value2

πŸŽ€ SETTING PARAMETERS DURING REQUEST'S EXECUTION πŸŽ€

use set-param to replace the value of an existing parameter, or create a new one. for instance:

get-param par1
...
set-param par1="new value"

in this case the value of an existing parameter "par1" is replaced with "new value". in the following code a new parameter is created, which can be retrieved later with get-param:

set-param par1="new value"
get-param par1

see call-handler for more examples. πŸ‘‘


πŸ”₯ DUPLICATE INPUT PARAMETER NAMES πŸ”₯

if there are multiple input parameters with the same name set by the request caller, such as

http://<web address>/<app name>/<request name>?par=val1&par=val2

the value of input parameter "par" is undefined. do not specify multiple input parameters with the same name. fr fr, don't do it, it's giving chaos 😭


⭐ SEE ALSO ⭐

Request data

get-param request-body set-param See all documentation


and that's the whole page bestie, you're officially fluent in get-param πŸ’–

this was the GOLF(2gg) page, sourced from $VERSION and dated $DATE β€” mwah, slay, go write some requests 🌸

πŸ“¦ where this page comes from