Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Mar 22, 2023
1 parent ecf5094 commit f43ad42
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 148 deletions.
144 changes: 72 additions & 72 deletions coverage.out
Original file line number Diff line number Diff line change
Expand Up @@ -90,79 +90,79 @@ github.com/GolangToolKits/grrt/reqRoute.go:280.2,280.19 1 1
github.com/GolangToolKits/grrt/reqRoute.go:283.55,287.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:36.71,40.53 1 1
github.com/GolangToolKits/grrt/reqRouter.go:40.53,42.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:42.8,48.13 4 1
github.com/GolangToolKits/grrt/reqRouter.go:48.13,51.36 3 1
github.com/GolangToolKits/grrt/reqRouter.go:51.36,54.5 1 1
github.com/GolangToolKits/grrt/reqRouter.go:63.3,63.26 1 1
github.com/GolangToolKits/grrt/reqRouter.go:63.26,65.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:65.9,65.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:65.32,67.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:69.3,69.34 1 1
github.com/GolangToolKits/grrt/reqRouter.go:69.34,71.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:71.9,71.43 1 1
github.com/GolangToolKits/grrt/reqRouter.go:71.43,73.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:73.9,76.4 2 1
github.com/GolangToolKits/grrt/reqRouter.go:81.38,85.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:88.69,91.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:91.16,93.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:93.8,95.28 2 1
github.com/GolangToolKits/grrt/reqRouter.go:95.28,96.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:96.55,99.5 2 1
github.com/GolangToolKits/grrt/reqRouter.go:101.3,101.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:101.12,103.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:105.2,105.11 1 1
github.com/GolangToolKits/grrt/reqRouter.go:109.95,112.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:112.16,114.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:114.8,116.28 2 1
github.com/GolangToolKits/grrt/reqRouter.go:116.28,117.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:117.55,120.5 2 1
github.com/GolangToolKits/grrt/reqRouter.go:122.3,122.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:122.12,124.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:42.8,46.13 4 1
github.com/GolangToolKits/grrt/reqRouter.go:46.13,49.36 3 1
github.com/GolangToolKits/grrt/reqRouter.go:49.36,52.5 1 1
github.com/GolangToolKits/grrt/reqRouter.go:54.3,54.26 1 1
github.com/GolangToolKits/grrt/reqRouter.go:54.26,56.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:56.9,56.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:56.32,58.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:59.3,59.34 1 1
github.com/GolangToolKits/grrt/reqRouter.go:59.34,61.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:61.9,61.43 1 1
github.com/GolangToolKits/grrt/reqRouter.go:61.43,63.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:63.9,66.4 2 1
github.com/GolangToolKits/grrt/reqRouter.go:71.38,75.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:78.69,81.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:81.16,83.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:83.8,85.28 2 1
github.com/GolangToolKits/grrt/reqRouter.go:85.28,86.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:86.55,89.5 2 1
github.com/GolangToolKits/grrt/reqRouter.go:91.3,91.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:91.12,93.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:95.2,95.11 1 1
github.com/GolangToolKits/grrt/reqRouter.go:99.95,102.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:102.16,104.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:104.8,106.28 2 1
github.com/GolangToolKits/grrt/reqRouter.go:106.28,107.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:107.55,110.5 2 1
github.com/GolangToolKits/grrt/reqRouter.go:112.3,112.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:112.12,114.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:116.2,116.11 1 1
github.com/GolangToolKits/grrt/reqRouter.go:120.49,123.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:123.16,125.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:126.2,126.11 1 1
github.com/GolangToolKits/grrt/reqRouter.go:130.49,133.16 3 1
github.com/GolangToolKits/grrt/reqRouter.go:133.16,135.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:136.2,136.11 1 1
github.com/GolangToolKits/grrt/reqRouter.go:140.34,142.2 1 1
github.com/GolangToolKits/grrt/reqRouter.go:145.44,147.2 1 1
github.com/GolangToolKits/grrt/reqRouter.go:150.55,153.28 3 1
github.com/GolangToolKits/grrt/reqRouter.go:153.28,155.20 2 1
github.com/GolangToolKits/grrt/reqRouter.go:155.20,156.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:158.3,158.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:163.55,167.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:170.56,173.28 3 1
github.com/GolangToolKits/grrt/reqRouter.go:173.28,175.20 2 1
github.com/GolangToolKits/grrt/reqRouter.go:175.20,176.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:178.3,178.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:182.55,186.28 4 1
github.com/GolangToolKits/grrt/reqRouter.go:186.28,188.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:189.2,189.30 1 1
github.com/GolangToolKits/grrt/reqRouter.go:192.49,196.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:198.55,201.17 3 1
github.com/GolangToolKits/grrt/reqRouter.go:201.17,203.17 2 1
github.com/GolangToolKits/grrt/reqRouter.go:203.17,205.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:207.2,207.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:275.70,282.15 7 1
github.com/GolangToolKits/grrt/reqRouter.go:282.15,284.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:284.12,285.9 1 1
github.com/GolangToolKits/grrt/reqRouter.go:287.3,288.17 2 1
github.com/GolangToolKits/grrt/reqRouter.go:288.17,289.28 1 1
github.com/GolangToolKits/grrt/reqRouter.go:289.28,290.28 1 1
github.com/GolangToolKits/grrt/reqRouter.go:290.28,292.44 2 1
github.com/GolangToolKits/grrt/reqRouter.go:292.44,295.12 3 1
github.com/GolangToolKits/grrt/reqRouter.go:297.11,297.36 1 1
github.com/GolangToolKits/grrt/reqRouter.go:297.36,300.11 3 1
github.com/GolangToolKits/grrt/reqRouter.go:303.9,306.15 3 1
github.com/GolangToolKits/grrt/reqRouter.go:306.15,308.5 1 1
github.com/GolangToolKits/grrt/reqRouter.go:309.4,309.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:312.2,312.19 1 1
github.com/GolangToolKits/grrt/reqRouter.go:315.96,317.36 2 1
github.com/GolangToolKits/grrt/reqRouter.go:317.36,318.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:318.32,320.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:322.2,323.27 2 1
github.com/GolangToolKits/grrt/reqRouter.go:326.52,329.13 3 1
github.com/GolangToolKits/grrt/reqRouter.go:329.13,331.15 2 1
github.com/GolangToolKits/grrt/reqRouter.go:331.15,333.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:335.2,335.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:130.34,132.2 1 1
github.com/GolangToolKits/grrt/reqRouter.go:135.44,137.2 1 1
github.com/GolangToolKits/grrt/reqRouter.go:140.55,143.28 3 1
github.com/GolangToolKits/grrt/reqRouter.go:143.28,145.20 2 1
github.com/GolangToolKits/grrt/reqRouter.go:145.20,146.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:148.3,148.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:153.55,157.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:160.56,163.28 3 1
github.com/GolangToolKits/grrt/reqRouter.go:163.28,165.20 2 1
github.com/GolangToolKits/grrt/reqRouter.go:165.20,166.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:168.3,168.55 1 1
github.com/GolangToolKits/grrt/reqRouter.go:172.55,176.28 4 1
github.com/GolangToolKits/grrt/reqRouter.go:176.28,178.3 1 1
github.com/GolangToolKits/grrt/reqRouter.go:179.2,179.30 1 1
github.com/GolangToolKits/grrt/reqRouter.go:182.49,186.2 3 1
github.com/GolangToolKits/grrt/reqRouter.go:188.55,191.17 3 1
github.com/GolangToolKits/grrt/reqRouter.go:191.17,193.17 2 1
github.com/GolangToolKits/grrt/reqRouter.go:193.17,195.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:197.2,197.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:200.70,207.15 7 1
github.com/GolangToolKits/grrt/reqRouter.go:207.15,209.12 1 1
github.com/GolangToolKits/grrt/reqRouter.go:209.12,210.9 1 1
github.com/GolangToolKits/grrt/reqRouter.go:212.3,213.17 2 1
github.com/GolangToolKits/grrt/reqRouter.go:213.17,214.28 1 1
github.com/GolangToolKits/grrt/reqRouter.go:214.28,215.28 1 1
github.com/GolangToolKits/grrt/reqRouter.go:215.28,217.44 2 1
github.com/GolangToolKits/grrt/reqRouter.go:217.44,220.12 3 1
github.com/GolangToolKits/grrt/reqRouter.go:222.11,222.36 1 1
github.com/GolangToolKits/grrt/reqRouter.go:222.36,225.11 3 1
github.com/GolangToolKits/grrt/reqRouter.go:228.9,231.15 3 1
github.com/GolangToolKits/grrt/reqRouter.go:231.15,233.5 1 1
github.com/GolangToolKits/grrt/reqRouter.go:234.4,234.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:237.2,237.19 1 1
github.com/GolangToolKits/grrt/reqRouter.go:240.96,242.36 2 1
github.com/GolangToolKits/grrt/reqRouter.go:242.36,243.32 1 1
github.com/GolangToolKits/grrt/reqRouter.go:243.32,245.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:247.2,248.27 2 1
github.com/GolangToolKits/grrt/reqRouter.go:251.52,255.25 4 1
github.com/GolangToolKits/grrt/reqRouter.go:255.25,257.15 2 1
github.com/GolangToolKits/grrt/reqRouter.go:257.15,259.4 1 1
github.com/GolangToolKits/grrt/reqRouter.go:261.2,261.12 1 1
github.com/GolangToolKits/grrt/router.go:29.25,34.2 4 1
github.com/GolangToolKits/grrt/router.go:37.46,39.49 2 1
github.com/GolangToolKits/grrt/router.go:39.49,41.3 1 1
Expand Down
78 changes: 2 additions & 76 deletions reqRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ func (t *ReqRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
t.handleCors(w)
} else {
path := r.URL.Path
// var rt = t.findPrefix(path)
var rt Route
// if rt == nil {
sfile := t.isStaticFile(path)
if !sfile {
frt, fvars := t.findRouteAndVars(path)
Expand All @@ -53,19 +51,11 @@ func (t *ReqRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// rt = frt
}
}
// frt, fvars := t.findRouteAndVars(path)
// rt = frt
// if rt != nil && len(*fvars) > 0 {
// r = t.requestWithVars(r, rt.GetVarNames(), fvars)
// // rt = frt
// }
// }
if rt == nil && !sfile {
rt = t.findPrefix(path)
} else if rt == nil && sfile {
rt = t.findFilePrefix(path)
}
// rt = t.findPrefix(path)
if rt == nil || !rt.IsActive() {
w.WriteHeader(http.StatusNotFound)
} else if !rt.IsMethodAllowed(r.Method) {
Expand Down Expand Up @@ -207,71 +197,6 @@ func (t *ReqRouter) findFilePrefix(path string) Route {
return rtn
}

// func (t *ReqRouter) findRouteAndVars(path string) (Route, *[]string) {
// var rnt Route
// sp := strings.Split(path, "/")
// var vars []string
// // var vcnt = len(sp) - 2
// var vl int
// if len(sp) == 2 && sp[1] == "" {
// vl = len(sp) - 2
// } else {
// vl = len(sp) - 1
// }
// var vcnt = vl
// //log.Println("sp:", sp)
// var found = false
// var searchPath = ""
// for i, p := range sp {
// //if i == 0 {
// //continue
// if found {
// break
// }
// // if i == 0 {
// // continue
// // } else if found {
// // break
// // }
// // searchPath += "/" + p
// if searchPath == "/" {
// searchPath += p
// } else {
// searchPath += "/" + p
// }
// // searchPath += "/" + p
// rts := t.namedRoutes[searchPath]
// if rts != nil {
// var baser = true
// for _, rt := range *rts {
// if rt.GetPath() != "/" {
// baser = false
// break
// }
// }

// for _, rt := range *rts {
// if rt.GetPathVarsCount() == vcnt {
// rnt = rt
// found = true
// vars = sp[i+1:]
// if len(vars) == 1 && vars[0] == "" {
// vars = []string{}
// }
// break
// // } else if rt.GetPath() == "/" && !rt.IsPathVarsUsed() {
// // } else if len(*rts) == 1 && rt.GetPath() == "/" && !rt.IsPathVarsUsed() {
// } else if baser {
// vcnt--
// }
// }
// } else {
// vcnt--
// }
// }
// return rnt, &vars
// }

func (t *ReqRouter) findRouteAndVars(path string) (Route, *[]string) {
var rnt Route
sp := strings.Split(path, "/")
Expand Down Expand Up @@ -326,7 +251,8 @@ func (t *ReqRouter) requestWithVars(r *http.Request, pVarNames, pvars *[]string)
func (t *ReqRouter) isStaticFile(path string) bool {
var rtn bool
var ind = strings.LastIndex(path, ".")
if ind > 0 {
var ind2 = strings.LastIndex(path, "@")
if ind > 0 && ind2 < 0 {
disp := len(path) - (ind + 1)
if disp < 4 {
rtn = true
Expand Down

0 comments on commit f43ad42

Please sign in to comment.