2017-12-14 04:56:23 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/kataras/iris/_examples/tutorial/vuejs-todo-mvc/src/todo"
|
|
|
|
"github.com/kataras/iris/_examples/tutorial/vuejs-todo-mvc/src/web/controllers"
|
|
|
|
|
|
|
|
"github.com/kataras/iris"
|
|
|
|
"github.com/kataras/iris/sessions"
|
2017-12-23 16:07:39 +01:00
|
|
|
"github.com/kataras/iris/websocket"
|
2017-12-16 05:38:28 +01:00
|
|
|
|
|
|
|
"github.com/kataras/iris/mvc"
|
2017-12-14 04:56:23 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := iris.New()
|
2017-12-23 16:07:39 +01:00
|
|
|
|
2017-12-14 04:56:23 +01:00
|
|
|
// serve our app in public, public folder
|
|
|
|
// contains the client-side vue.js application,
|
|
|
|
// no need for any server-side template here,
|
|
|
|
// actually if you're going to just use vue without any
|
|
|
|
// back-end services, you can just stop afer this line and start the server.
|
|
|
|
app.StaticWeb("/", "./public")
|
|
|
|
|
|
|
|
sess := sessions.New(sessions.Config{
|
2017-12-23 16:07:39 +01:00
|
|
|
Cookie: "iris_session",
|
2017-12-14 04:56:23 +01:00
|
|
|
})
|
|
|
|
|
2017-12-23 16:07:39 +01:00
|
|
|
ws := websocket.New(websocket.Config{})
|
2017-12-14 04:56:23 +01:00
|
|
|
|
2017-12-23 16:07:39 +01:00
|
|
|
// create our mvc application targeted to /todos relative sub path.
|
|
|
|
m := mvc.New(app.Party("/todos"))
|
2017-12-16 05:38:28 +01:00
|
|
|
// any dependencies bindings here...
|
|
|
|
m.AddDependencies(
|
2017-12-23 16:07:39 +01:00
|
|
|
todo.NewMemoryService(),
|
2017-12-16 05:38:28 +01:00
|
|
|
mvc.Session(sess),
|
2017-12-23 16:07:39 +01:00
|
|
|
ws.Upgrade,
|
2017-12-16 05:38:28 +01:00
|
|
|
)
|
2017-12-14 04:56:23 +01:00
|
|
|
|
2017-12-23 16:07:39 +01:00
|
|
|
// http://localhost:8080/iris-ws.js
|
|
|
|
// serve the javascript client library to communicate with
|
|
|
|
// the iris high level websocket event system.
|
|
|
|
m.Router.Any("/iris-ws.js", websocket.ClientHandler())
|
|
|
|
|
2017-12-14 04:56:23 +01:00
|
|
|
// controllers registration here...
|
2017-12-16 05:38:28 +01:00
|
|
|
m.Register(new(controllers.TodoController))
|
2017-12-14 04:56:23 +01:00
|
|
|
|
|
|
|
// start the web server at http://localhost:8080
|
2017-12-23 16:07:39 +01:00
|
|
|
app.Run(iris.Addr(":8080"), iris.WithoutVersionChecker)
|
2017-12-14 04:56:23 +01:00
|
|
|
}
|