mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
Nothing special here
On websocket: https://github.com/kataras/iris/issues/340#issuecomment-237612680
This commit is contained in:
parent
922248bbf1
commit
2b364817c3
1
iris.go
1
iris.go
|
@ -1820,7 +1820,6 @@ func (api *muxAPI) Favicon(favPath string, requestPath ...string) RouteNameFunc
|
||||||
if len(requestPath) > 0 {
|
if len(requestPath) > 0 {
|
||||||
reqPath = requestPath[0]
|
reqPath = requestPath[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Head(reqPath, h)
|
api.Head(reqPath, h)
|
||||||
return api.Get(reqPath, h)
|
return api.Get(reqPath, h)
|
||||||
}
|
}
|
||||||
|
|
13
template.go
13
template.go
|
@ -104,6 +104,15 @@ type (
|
||||||
// Directory sets the directory to load from
|
// Directory sets the directory to load from
|
||||||
// returns the Binary location which is optional
|
// returns the Binary location which is optional
|
||||||
func (t *TemplateEngineLocation) Directory(dir string, fileExtension string) *TemplateEngineBinaryLocation {
|
func (t *TemplateEngineLocation) Directory(dir string, fileExtension string) *TemplateEngineBinaryLocation {
|
||||||
|
if dir == "" {
|
||||||
|
dir = DefaultTemplateDirectory // the default templates dir
|
||||||
|
}
|
||||||
|
if fileExtension == "" {
|
||||||
|
fileExtension = DefaultTemplateExtension
|
||||||
|
} else if fileExtension[0] != '.' { // if missing the start dot
|
||||||
|
fileExtension = "." + fileExtension
|
||||||
|
}
|
||||||
|
|
||||||
t.directory = dir
|
t.directory = dir
|
||||||
t.extension = fileExtension
|
t.extension = fileExtension
|
||||||
return &TemplateEngineBinaryLocation{location: t}
|
return &TemplateEngineBinaryLocation{location: t}
|
||||||
|
@ -111,6 +120,10 @@ func (t *TemplateEngineLocation) Directory(dir string, fileExtension string) *Te
|
||||||
|
|
||||||
// Binary sets the asset(s) and asssets names to load from, works with Directory
|
// Binary sets the asset(s) and asssets names to load from, works with Directory
|
||||||
func (t *TemplateEngineBinaryLocation) Binary(assetFn func(name string) ([]byte, error), namesFn func() []string) {
|
func (t *TemplateEngineBinaryLocation) Binary(assetFn func(name string) ([]byte, error), namesFn func() []string) {
|
||||||
|
if assetFn == nil || namesFn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
t.location.assetFn = assetFn
|
t.location.assetFn = assetFn
|
||||||
t.location.namesFn = namesFn
|
t.location.namesFn = namesFn
|
||||||
// if extension is not static(setted by .Directory)
|
// if extension is not static(setted by .Directory)
|
||||||
|
|
|
@ -201,7 +201,9 @@ func (s *websocketServer) serve() {
|
||||||
case join := <-s.join:
|
case join := <-s.join:
|
||||||
s.joinRoom(join.roomName, join.websocketConnectionID)
|
s.joinRoom(join.roomName, join.websocketConnectionID)
|
||||||
case leave := <-s.leave:
|
case leave := <-s.leave:
|
||||||
|
if _, found := s.websocketConnections[leave.websocketConnectionID]; found {
|
||||||
s.leaveRoom(leave.roomName, leave.websocketConnectionID)
|
s.leaveRoom(leave.roomName, leave.websocketConnectionID)
|
||||||
|
}
|
||||||
case msg := <-s.messages: // message received from the websocketConnection
|
case msg := <-s.messages: // message received from the websocketConnection
|
||||||
if msg.to != All && msg.to != NotMe && s.rooms[msg.to] != nil {
|
if msg.to != All && msg.to != NotMe && s.rooms[msg.to] != nil {
|
||||||
// it suppose to send the message to a room
|
// it suppose to send the message to a room
|
||||||
|
|
Loading…
Reference in New Issue
Block a user