Replaces gorilla mux to goji and decied to remove vendor dependencies from git (#28)
* Replaces gorilla mux to goji Removed the applicationContext stuff. Now every handler is a struct, and each one hold its dependencies. * handler not handle * Ignoring vendor dir * Hide handlers complexity instantiation. * Websocket handler does not need common handlers * Use maps instead of for loops to search in memdb for apps (#29) * Use maps instead of for loops to search in memdb for apps; use mutexes more efficiently by immediately unlocking when lock is no longer needed, not just at the end of the function via defer * Fixed assignment to entry in nil map * Minor impovements in source code * Replaces gorilla mux to goji Removed the applicationContext stuff. Now every handler is a struct, and each one hold its dependencies. * handler not handle * Ignoring vendor dir * Hide handlers complexity instantiation. * Websocket handler does not need common handlers * renamed IdMutex to IDMutex to follow go convention
This commit is contained in:
+10
-15
@@ -11,6 +11,10 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"goji.io/pat"
|
||||
|
||||
goji "goji.io"
|
||||
|
||||
log "github.com/golang/glog"
|
||||
)
|
||||
|
||||
@@ -41,21 +45,12 @@ func Start(filename string) {
|
||||
db.AddApp(newAppFromConfig(a))
|
||||
}
|
||||
|
||||
// Creating the global application context
|
||||
ctx := &applicationContext{DB: db}
|
||||
|
||||
// The router
|
||||
router := newRouter(ctx)
|
||||
|
||||
router.POST("/apps/{app_id}/events", commonHandlers(ctx, postEvents))
|
||||
|
||||
router.GET("/apps/{app_id}/channels", commonHandlers(ctx, getChannels))
|
||||
|
||||
router.GET("/apps/{app_id}/channels/{channel_name}", commonHandlers(ctx, getChannel))
|
||||
|
||||
router.GET("/apps/{app_id}/channels/{channel_name}/users", commonHandlers(ctx, getChannelUsers))
|
||||
|
||||
router.GET("/app/{key}", contextHandlerFunc(wsHandler))
|
||||
router := goji.NewMux()
|
||||
router.HandleFuncC(pat.Post("/apps/:app_id/events"), newPostEventsHandler(db))
|
||||
router.HandleFuncC(pat.Get("/apps/:app_id/channels"), newGetChannelsHandler(db))
|
||||
router.HandleFuncC(pat.Get("/apps/:app_id/channels/:channel_name"), newGetChannelHandler(db))
|
||||
router.HandleFuncC(pat.Get("/apps/:app_id/channels/:channel_name/users"), newGetChannelUsersHandler(db))
|
||||
router.HandleC(pat.Get("/app/:key"), newWebsocketHandler(db))
|
||||
|
||||
if conf.SSL {
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user