Comments (5)
Solid idea! I've pushed a branch called issue-5
(2de33f6) that breaks out the Run()
function in to Run()
and Init()
with Init()
allows you to add the application routes to a router you pass in to the function. It still requires a gorilla/mux
router (*mux.Router
) but this simple example I worked up works...
package main
import (
"github.com/gorilla/mux"
"net/http"
alexa "github.com/mikeflynn/go-alexa/skillserver"
)
func YourHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Gorilla!\n"))
}
func EchoIntentHandler(echoReq *alexa.EchoRequest, echoResp *alexa.EchoResponse) {
echoResp.OutputSpeech("Hello world from my new Echo test app!").Card("Hello World", "This is a test card.")
}
func main() {
var Applications = map[string]interface{}{
"/echo/helloworld": alexa.EchoApplication{ // Route
AppID: "xxxxxxxx", // Echo App ID from Amazon Dashboard
OnIntent: EchoIntentHandler,
OnLaunch: EchoIntentHandler,
},
}
r := mux.NewRouter()
r.HandleFunc("/", YourHandler)
alexa.Init(Applications, r)
http.ListenAndServe(":8100", r)
}
Take a look at the branch when you get a chance and let me know if that works for you.
from go-alexa.
Cool, hopefully I'll get a chance to try it out next week. The way I hacked around it was to run the go-alexa server in a goroutine, and using net/http/util's NewSingleHostReverseProxy
from go-alexa.
I'm going to go ahead and merge this change in to master since it doesn't change how the primary use case works. Let me know if there's more to do here when you get a chance to play with it.
from go-alexa.
Awesome, just had a chance to check it, and it works perfectly.
It's a great change from the workaround I hacked together where I was using httputil.NewSingleHostReverseProxy()
to proxy to the alexa server running in a different goroutine.
from go-alexa.
Good to hear! I love that hack but glad this simple change made things easier for you.
from go-alexa.
Related Issues (12)
- Web Builder Interface For Easy Creation of Skills? HOT 1
- Amazon Timestamp bug. json changed from string to int HOT 3
- Jeopardy Example is not bumped to newest context import HOT 6
- Dialog Interface Reference
- Proposal: separate alexa request/response from http server HOT 27
- Device Id in Request
- AudioPlayer requests failing at application ID verification HOT 1
- Remove "Go isn't an option on Lamda" from /skillserver README HOT 1
- Init Went Away
- Please avoid parsing command line flags HOT 1
- Broken under Go 1.7 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-alexa.