The word you're looking for is function. Where you see 'void loop()' and so on, void is the return type of the function.
I suggest you encode your command in the URL of the HTTP request. Reading characters from a client connection to buffer the HTTP request string is just like reading characters from the hardware Serial port to buffer an incoming string.
There are conventional ways to URL-encode arguments to a request as ?name1=value1&name2=value2' and so on, where name1 etc represent names that you will define, and value1 etc represent values provided for that parameter. Once you have buffered the incoming HTTP request and identified the part containing the URL, you can use strtok to separate out the parameter assignments. You should find plenty of examples of Arduino web servers showing how to parse the incoming request to get the parameter values.