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 ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" | |
) |
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
type QResponse struct { | |
ID string `json:"id"` | |
Timestamp time.Time `json:"timestamp"` | |
Result struct { | |
Source string `json:"source"` | |
ResolvedQuery string `json:"resolvedQuery"` | |
Action string `json:"action"` | |
ActionIncomplete bool `json:"actionIncomplete"` | |
Parameters struct { | |
Name string `json:"name"` |
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
{ | |
"id": "cfcbd337-6b66-4393-a6a3-74fc5487cedb", | |
"timestamp": "2016-02-16T00:30:13.529Z", | |
"result": { | |
"source": "agent", | |
"resolvedQuery": "hi my name is Sam", | |
"action": "greetings", | |
"actionIncomplete": false, | |
"parameters": { | |
"name": "Sam" |
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" | |
"fmt" | |
"log" | |
"net/http" | |
"time" | |
) |
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/base64" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
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
{ | |
"requests":[ | |
{ | |
"image":{ | |
"content":"<base64-encoded-image-bytes>" | |
}, | |
"features":[ | |
{ | |
"type":"<FEATURE_TYPE>", | |
"maxResults":1 |
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/base64" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
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 ( | |
"flag" | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
func main() { |
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
func process(w http.ResponseWriter, r *http.Request) { | |
rand.Seed(time.Now().Unix()) | |
var t *template.Template | |
if rand.Intn(10) > 5 { | |
t, _ = template.ParseFiles("layout.html", "red_hello.html") | |
} else { | |
t, _ = template.ParseFiles("layout.html", "blue_hello.html") | |
} | |
t.ExecuteTemplate(w, "layout", "") | |
} |
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
{{ define "content" }} | |
<h1 style="color: blue;">Hello World!</h1> | |
{{ end }} |