I forgot to use sort.Sort lawl
This commit is contained in:
Makis Maropoulos 2016-06-18 20:26:35 +03:00
parent 78aa4f7681
commit 15139e33b7
3 changed files with 9 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"net/http/pprof" "net/http/pprof"
"os" "os"
"sort"
"strings" "strings"
"sync" "sync"
@ -1217,8 +1218,9 @@ func (mux *serveMux) register(method []byte, subdomain string, path string, midd
// build collects all routes info and adds them to the registry in order to be served from the request handler // build collects all routes info and adds them to the registry in order to be served from the request handler
// this happens once when server is setting the mux's handler. // this happens once when server is setting the mux's handler.
func (mux *serveMux) build() { func (mux *serveMux) build() {
routes := bySubdomain(mux.lookups)
for _, r := range routes { sort.Sort(bySubdomain(mux.lookups))
for _, r := range mux.lookups {
// add to the registry tree // add to the registry tree
tree := mux.getTree(r.method, r.subdomain) tree := mux.getTree(r.method, r.subdomain)
if tree == nil { if tree == nil {
@ -1260,7 +1262,6 @@ func (mux *serveMux) ServeRequest() fasthttp.RequestHandler {
// initialize the router once // initialize the router once
mux.build() mux.build()
// optimize this once once, we could do that: context.RequestPath(mux.escapePath), but we lose some nanoseconds on if :) // optimize this once once, we could do that: context.RequestPath(mux.escapePath), but we lose some nanoseconds on if :)
getRequestPath := func(reqCtx *fasthttp.RequestCtx) string { getRequestPath := func(reqCtx *fasthttp.RequestCtx) string {
return utils.BytesToString(reqCtx.Path()) return utils.BytesToString(reqCtx.Path())

View File

@ -108,7 +108,10 @@ func (i *iriscontrol) initializeChild() {
}) })
i.child.UseFunc(func(ctx *iris.Context) { i.child.UseFunc(func(ctx *iris.Context) {
///TODO: Remove this and make client-side basic auth when websocket connection. ///TODO: Remove this and make client-side basic auth when websocket connection. (user@password/host.. on chronium)
// FOR GOOGLE CHROME/CHRONIUM
// https://bugs.chromium.org/p/chromium/issues/detail?id=123862
// CROSS DOMAIN IS DISABLED so I think this is ok solution for now...
if ctx.PathString() == i.child.Config.Websocket.Endpoint { if ctx.PathString() == i.child.Config.Websocket.Endpoint {
ctx.Next() ctx.Next()
return return

View File

@ -77,6 +77,4 @@ func (i *iriscontrol) GetDescription() string {
// PreClose any clean-up // PreClose any clean-up
// temporary is empty because all resources are cleaned graceful by the iris' station // temporary is empty because all resources are cleaned graceful by the iris' station
func (i *iriscontrol) PreClose(s *iris.Framework) { func (i *iriscontrol) PreClose(s *iris.Framework) {}
s.Logger.Infof("Main server terminated")
}