Added support for Ruby v2 Specialization (#1101)
* Added support for Ruby v2 Specialization * Added ruby v2 example with builder code
This commit is contained in:
committed by
Ta-Ching Chen
parent
f104f0b46b
commit
c717f182b6
@@ -105,3 +105,11 @@ $ curl http://$FISSION_ROUTER/request/123?key=abc
|
||||
--BODY--
|
||||
|
||||
```
|
||||
|
||||
## V2 Specification Example (with builder support)
|
||||
|
||||
```
|
||||
$ fission function create --name parse --env ruby --src "parse/*" --entrypoint handler
|
||||
$ fission fn test --name parse --body '<message>This is my message</message>'
|
||||
This is my message
|
||||
```
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
||||
|
||||
gem "nokogiri"
|
||||
@@ -0,0 +1,15 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
mini_portile2 (2.4.0)
|
||||
nokogiri (1.10.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
nokogiri
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'nokogiri'
|
||||
|
||||
def handler(context)
|
||||
context.logger.info("Received request")
|
||||
|
||||
doc = Nokogiri::XML(context.request.body.read)
|
||||
ele = doc.at_xpath('//message')
|
||||
msg = ele.nil? ? 'No Message' : ele.content
|
||||
|
||||
Rack::Response.new([msg, "\n"]).finish
|
||||
end
|
||||
Reference in New Issue
Block a user