diff --git a/core/router/fs.go b/core/router/fs.go index d2729b46..7d4ed486 100644 --- a/core/router/fs.go +++ b/core/router/fs.go @@ -19,6 +19,8 @@ import ( const indexName = "/index.html" +// DirOptions contains the optional settings that +// `FileServer` and `Party#HandleDir` can use to serve files and assets. type DirOptions struct { // Defaults to "/index.html", if request path is ending with **/*/$IndexName // then it redirects to **/*(/) which another handler is handling it, @@ -163,6 +165,12 @@ func (f *embeddedDir) Readdir(count int) ([]os.FileInfo, error) { return f.list, nil } +// FileServer returns a Handler which serves files from a specific system, phyisical, directory +// or an embedded one. +// The first parameter is the directory, relative to the executable program. +// The second optional parameter is any optional settings that the caller can use. +// +// See `Party#HandleDir` too. // Examples can be found at: https://github.com/kataras/iris/tree/master/_examples/file-server func FileServer(directory string, opts ...DirOptions) context.Handler { if directory == "" { diff --git a/core/router/handler.go b/core/router/handler.go index bcf41cea..4091e241 100644 --- a/core/router/handler.go +++ b/core/router/handler.go @@ -1,7 +1,6 @@ package router import ( - "html" "net/http" "sort" "strings" @@ -168,17 +167,6 @@ func (h *routerHandler) HandleRequest(ctx context.Context) { } ctx.Redirect(url, http.StatusMovedPermanently) - - // RFC2616 recommends that a short note "SHOULD" be included in the - // response because older user agents may not understand 301/307. - // Shouldn't send the response for POST or HEAD; that leaves GET. - if method == http.MethodGet { - note := "Moved Permanently.\n" - - ctx.ResponseWriter().WriteString(note) - } return } diff --git a/websocket/websocket.go b/websocket/websocket.go index 6b14ef7f..e21a5536 100644 --- a/websocket/websocket.go +++ b/websocket/websocket.go @@ -49,12 +49,10 @@ var ( // See examples for more. Dial = neffos.Dial - // IsTryingToReconnect reports whether the "err" is from a client - // that was trying to reconnect to the websocket server, - // the first output parameter is the number of total reconnection retries, - // including the previous failures and the succeed last one. + // IsTryingToReconnect reports whether the returning "err" from the `Server#Upgrade` + // is from a client that was trying to reconnect to the websocket server. // - // Use it on registered callbacks for `Server#OnUpgradeError`. + // Look the `Conn#WasReconnected` and `Conn#ReconnectTries` too. IsTryingToReconnect = neffos.IsTryingToReconnect // OnNamespaceConnect is the event name which its callback is fired right before namespace connect,