日時: | 2017-07-21 |
---|---|
作: | @voluntas |
バージョン: | 0.6.0 |
URL: | https://voluntas.githu.io/ |
突っ込みは Twitter @voluntas まで。
Responding to requests via simple route matching is built in to Go's net/http
standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe
to have the default request handler invoked on each request. For example:
package main
import (
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function getInstance(consumer_key, consumer_secret) { | |
return new TwitterWebService_(consumer_key, consumer_secret); | |
} | |
var TwitterWebService_ = function (consumer_key, consumer_secret) { | |
this.consumer_key = consumer_key; | |
this.consumer_secret = consumer_secret; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run this, name this file hello_world.yml and run the following in the same directory | |
# ansible-playbook hello_world.yml -i 'local,' --connection=local | |
- hosts: | |
- local | |
tasks: | |
- name: Create a directory | |
file: path=hello_world state=directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm -v | |
module.js:338 | |
throw err; | |
^ | |
Error: Cannot find module 'npmlog' | |
at Function.Module._resolveFilename (module.js:336:15) | |
at Function.Module._load (module.js:278:25) | |
at Module.require (module.js:365:17) | |
at require (module.js:384:17) | |
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:18:11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"Regexp" | |
) | |
type route struct { | |
pattern *regexp.Regexp | |
handler http.Handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
type Message struct { |