Method: FunctionsFramework.http
- Defined in:
- lib/functions_framework.rb
.http(name = DEFAULT_TARGET) ⇒ self
Define a function that responds to HTTP requests.
You must provide a name for the function, and a block that implements the
function. The block should take a single Rack::Request argument. It
should return one of the following:
- A standard 3-element Rack response array. See https://github.com/rack/rack/blob/main/SPEC.rdoc
- A
Rack::Responseobject. - A simple String that will be sent as the response body.
- A Hash object that will be encoded as JSON and sent as the response body.
Example
FunctionsFramework.http "my-function" do |request|
"I received a request for #{request.url}"
end
139 140 141 142 |
# File 'lib/functions_framework.rb', line 139 def http(name = DEFAULT_TARGET, &) global_registry.add_http(name, &) self end |