Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今までのSwift => これからのSwift

kosako
April 19, 2016

今までのSwift => これからのSwift

kosako

April 19, 2016
Tweet

More Decks by kosako

Other Decks in Programming

Transcript

  1. ײ૝ NodeͬΆ͍(swift) router.get("/hello") { _, response, next in response.setHeader("Content-Type", value:

    "text/html; charset=utf-8") do { try response.status(HttpStatusCode.OK).send("Hello Kitura").end() } catch {} next() } // Listen on port 8090 let server = HttpServer.listen(8090, delegate: router) Server.run()
  2. ײ૝ NodeͬΆ͍(node express) var express = require('express'); var app =

    express(); app.get('/hello', function (req, res) { res.send('Hello World!'); }); app.listen(3000, function () { console.log('Example app listening on port 3000!'); });
  3. help % wsk action -h usage: wsk action [-h] {create,update,invoke,get,delete,list}

    ... optional arguments: -h, --help show this help message and exit available commands: {create,update,invoke,get,delete,list} create create new action update update an existing action invoke invoke action get get action delete delete action list list all actions
  4. help % wsk action invoke -h usage: wsk action invoke

    [-h] [-u AUTH] [-p PARAM PARAM] [-b] [-r] name positional arguments: name the name of the action to invoke optional arguments: -h, --help show this help message and exit -u AUTH, --auth AUTH authorization key -p PARAM PARAM, --param PARAM PARAM parameters -b, --blocking blocking invoke -r, --result show only activation result if a blocking activation (unless there is a failure)
  5. Hello world wsk action invoke /whisk.system/samples/echo -p message hello --blocking

    ok: invoked /whisk.system/samples/echo with id 003af1 response: { "result": { "message": "hello" }, "status": "success", "success": true }
  6. Post to slack POST wsk action invoke --blocking --result /whisk.system/

    slack/post --param username webhookbot --param text 'Hello world from openWhisk' --param url 'https:// hooks.slack.com/services/sample/sample/sample' -- param channel #target_channel