Skip to content

Commit f43ad42

Browse files
committed
update
1 parent ecf5094 commit f43ad42

File tree

2 files changed

+74
-148
lines changed

2 files changed

+74
-148
lines changed

coverage.out

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -90,79 +90,79 @@ github.com/GolangToolKits/grrt/reqRoute.go:280.2,280.19 1 1
9090
github.com/GolangToolKits/grrt/reqRoute.go:283.55,287.2 3 1
9191
github.com/GolangToolKits/grrt/reqRouter.go:36.71,40.53 1 1
9292
github.com/GolangToolKits/grrt/reqRouter.go:40.53,42.3 1 1
93-
github.com/GolangToolKits/grrt/reqRouter.go:42.8,48.13 4 1
94-
github.com/GolangToolKits/grrt/reqRouter.go:48.13,51.36 3 1
95-
github.com/GolangToolKits/grrt/reqRouter.go:51.36,54.5 1 1
96-
github.com/GolangToolKits/grrt/reqRouter.go:63.3,63.26 1 1
97-
github.com/GolangToolKits/grrt/reqRouter.go:63.26,65.4 1 1
98-
github.com/GolangToolKits/grrt/reqRouter.go:65.9,65.32 1 1
99-
github.com/GolangToolKits/grrt/reqRouter.go:65.32,67.4 1 1
100-
github.com/GolangToolKits/grrt/reqRouter.go:69.3,69.34 1 1
101-
github.com/GolangToolKits/grrt/reqRouter.go:69.34,71.4 1 1
102-
github.com/GolangToolKits/grrt/reqRouter.go:71.9,71.43 1 1
103-
github.com/GolangToolKits/grrt/reqRouter.go:71.43,73.4 1 1
104-
github.com/GolangToolKits/grrt/reqRouter.go:73.9,76.4 2 1
105-
github.com/GolangToolKits/grrt/reqRouter.go:81.38,85.2 3 1
106-
github.com/GolangToolKits/grrt/reqRouter.go:88.69,91.16 3 1
107-
github.com/GolangToolKits/grrt/reqRouter.go:91.16,93.3 1 1
108-
github.com/GolangToolKits/grrt/reqRouter.go:93.8,95.28 2 1
109-
github.com/GolangToolKits/grrt/reqRouter.go:95.28,96.55 1 1
110-
github.com/GolangToolKits/grrt/reqRouter.go:96.55,99.5 2 1
111-
github.com/GolangToolKits/grrt/reqRouter.go:101.3,101.12 1 1
112-
github.com/GolangToolKits/grrt/reqRouter.go:101.12,103.4 1 1
113-
github.com/GolangToolKits/grrt/reqRouter.go:105.2,105.11 1 1
114-
github.com/GolangToolKits/grrt/reqRouter.go:109.95,112.16 3 1
115-
github.com/GolangToolKits/grrt/reqRouter.go:112.16,114.3 1 1
116-
github.com/GolangToolKits/grrt/reqRouter.go:114.8,116.28 2 1
117-
github.com/GolangToolKits/grrt/reqRouter.go:116.28,117.55 1 1
118-
github.com/GolangToolKits/grrt/reqRouter.go:117.55,120.5 2 1
119-
github.com/GolangToolKits/grrt/reqRouter.go:122.3,122.12 1 1
120-
github.com/GolangToolKits/grrt/reqRouter.go:122.12,124.4 1 1
93+
github.com/GolangToolKits/grrt/reqRouter.go:42.8,46.13 4 1
94+
github.com/GolangToolKits/grrt/reqRouter.go:46.13,49.36 3 1
95+
github.com/GolangToolKits/grrt/reqRouter.go:49.36,52.5 1 1
96+
github.com/GolangToolKits/grrt/reqRouter.go:54.3,54.26 1 1
97+
github.com/GolangToolKits/grrt/reqRouter.go:54.26,56.4 1 1
98+
github.com/GolangToolKits/grrt/reqRouter.go:56.9,56.32 1 1
99+
github.com/GolangToolKits/grrt/reqRouter.go:56.32,58.4 1 1
100+
github.com/GolangToolKits/grrt/reqRouter.go:59.3,59.34 1 1
101+
github.com/GolangToolKits/grrt/reqRouter.go:59.34,61.4 1 1
102+
github.com/GolangToolKits/grrt/reqRouter.go:61.9,61.43 1 1
103+
github.com/GolangToolKits/grrt/reqRouter.go:61.43,63.4 1 1
104+
github.com/GolangToolKits/grrt/reqRouter.go:63.9,66.4 2 1
105+
github.com/GolangToolKits/grrt/reqRouter.go:71.38,75.2 3 1
106+
github.com/GolangToolKits/grrt/reqRouter.go:78.69,81.16 3 1
107+
github.com/GolangToolKits/grrt/reqRouter.go:81.16,83.3 1 1
108+
github.com/GolangToolKits/grrt/reqRouter.go:83.8,85.28 2 1
109+
github.com/GolangToolKits/grrt/reqRouter.go:85.28,86.55 1 1
110+
github.com/GolangToolKits/grrt/reqRouter.go:86.55,89.5 2 1
111+
github.com/GolangToolKits/grrt/reqRouter.go:91.3,91.12 1 1
112+
github.com/GolangToolKits/grrt/reqRouter.go:91.12,93.4 1 1
113+
github.com/GolangToolKits/grrt/reqRouter.go:95.2,95.11 1 1
114+
github.com/GolangToolKits/grrt/reqRouter.go:99.95,102.16 3 1
115+
github.com/GolangToolKits/grrt/reqRouter.go:102.16,104.3 1 1
116+
github.com/GolangToolKits/grrt/reqRouter.go:104.8,106.28 2 1
117+
github.com/GolangToolKits/grrt/reqRouter.go:106.28,107.55 1 1
118+
github.com/GolangToolKits/grrt/reqRouter.go:107.55,110.5 2 1
119+
github.com/GolangToolKits/grrt/reqRouter.go:112.3,112.12 1 1
120+
github.com/GolangToolKits/grrt/reqRouter.go:112.12,114.4 1 1
121+
github.com/GolangToolKits/grrt/reqRouter.go:116.2,116.11 1 1
122+
github.com/GolangToolKits/grrt/reqRouter.go:120.49,123.16 3 1
123+
github.com/GolangToolKits/grrt/reqRouter.go:123.16,125.3 1 1
121124
github.com/GolangToolKits/grrt/reqRouter.go:126.2,126.11 1 1
122-
github.com/GolangToolKits/grrt/reqRouter.go:130.49,133.16 3 1
123-
github.com/GolangToolKits/grrt/reqRouter.go:133.16,135.3 1 1
124-
github.com/GolangToolKits/grrt/reqRouter.go:136.2,136.11 1 1
125-
github.com/GolangToolKits/grrt/reqRouter.go:140.34,142.2 1 1
126-
github.com/GolangToolKits/grrt/reqRouter.go:145.44,147.2 1 1
127-
github.com/GolangToolKits/grrt/reqRouter.go:150.55,153.28 3 1
128-
github.com/GolangToolKits/grrt/reqRouter.go:153.28,155.20 2 1
129-
github.com/GolangToolKits/grrt/reqRouter.go:155.20,156.12 1 1
130-
github.com/GolangToolKits/grrt/reqRouter.go:158.3,158.55 1 1
131-
github.com/GolangToolKits/grrt/reqRouter.go:163.55,167.2 3 1
132-
github.com/GolangToolKits/grrt/reqRouter.go:170.56,173.28 3 1
133-
github.com/GolangToolKits/grrt/reqRouter.go:173.28,175.20 2 1
134-
github.com/GolangToolKits/grrt/reqRouter.go:175.20,176.12 1 1
135-
github.com/GolangToolKits/grrt/reqRouter.go:178.3,178.55 1 1
136-
github.com/GolangToolKits/grrt/reqRouter.go:182.55,186.28 4 1
137-
github.com/GolangToolKits/grrt/reqRouter.go:186.28,188.3 1 1
138-
github.com/GolangToolKits/grrt/reqRouter.go:189.2,189.30 1 1
139-
github.com/GolangToolKits/grrt/reqRouter.go:192.49,196.2 3 1
140-
github.com/GolangToolKits/grrt/reqRouter.go:198.55,201.17 3 1
141-
github.com/GolangToolKits/grrt/reqRouter.go:201.17,203.17 2 1
142-
github.com/GolangToolKits/grrt/reqRouter.go:203.17,205.4 1 1
143-
github.com/GolangToolKits/grrt/reqRouter.go:207.2,207.12 1 1
144-
github.com/GolangToolKits/grrt/reqRouter.go:275.70,282.15 7 1
145-
github.com/GolangToolKits/grrt/reqRouter.go:282.15,284.12 1 1
146-
github.com/GolangToolKits/grrt/reqRouter.go:284.12,285.9 1 1
147-
github.com/GolangToolKits/grrt/reqRouter.go:287.3,288.17 2 1
148-
github.com/GolangToolKits/grrt/reqRouter.go:288.17,289.28 1 1
149-
github.com/GolangToolKits/grrt/reqRouter.go:289.28,290.28 1 1
150-
github.com/GolangToolKits/grrt/reqRouter.go:290.28,292.44 2 1
151-
github.com/GolangToolKits/grrt/reqRouter.go:292.44,295.12 3 1
152-
github.com/GolangToolKits/grrt/reqRouter.go:297.11,297.36 1 1
153-
github.com/GolangToolKits/grrt/reqRouter.go:297.36,300.11 3 1
154-
github.com/GolangToolKits/grrt/reqRouter.go:303.9,306.15 3 1
155-
github.com/GolangToolKits/grrt/reqRouter.go:306.15,308.5 1 1
156-
github.com/GolangToolKits/grrt/reqRouter.go:309.4,309.32 1 1
157-
github.com/GolangToolKits/grrt/reqRouter.go:312.2,312.19 1 1
158-
github.com/GolangToolKits/grrt/reqRouter.go:315.96,317.36 2 1
159-
github.com/GolangToolKits/grrt/reqRouter.go:317.36,318.32 1 1
160-
github.com/GolangToolKits/grrt/reqRouter.go:318.32,320.4 1 1
161-
github.com/GolangToolKits/grrt/reqRouter.go:322.2,323.27 2 1
162-
github.com/GolangToolKits/grrt/reqRouter.go:326.52,329.13 3 1
163-
github.com/GolangToolKits/grrt/reqRouter.go:329.13,331.15 2 1
164-
github.com/GolangToolKits/grrt/reqRouter.go:331.15,333.4 1 1
165-
github.com/GolangToolKits/grrt/reqRouter.go:335.2,335.12 1 1
125+
github.com/GolangToolKits/grrt/reqRouter.go:130.34,132.2 1 1
126+
github.com/GolangToolKits/grrt/reqRouter.go:135.44,137.2 1 1
127+
github.com/GolangToolKits/grrt/reqRouter.go:140.55,143.28 3 1
128+
github.com/GolangToolKits/grrt/reqRouter.go:143.28,145.20 2 1
129+
github.com/GolangToolKits/grrt/reqRouter.go:145.20,146.12 1 1
130+
github.com/GolangToolKits/grrt/reqRouter.go:148.3,148.55 1 1
131+
github.com/GolangToolKits/grrt/reqRouter.go:153.55,157.2 3 1
132+
github.com/GolangToolKits/grrt/reqRouter.go:160.56,163.28 3 1
133+
github.com/GolangToolKits/grrt/reqRouter.go:163.28,165.20 2 1
134+
github.com/GolangToolKits/grrt/reqRouter.go:165.20,166.12 1 1
135+
github.com/GolangToolKits/grrt/reqRouter.go:168.3,168.55 1 1
136+
github.com/GolangToolKits/grrt/reqRouter.go:172.55,176.28 4 1
137+
github.com/GolangToolKits/grrt/reqRouter.go:176.28,178.3 1 1
138+
github.com/GolangToolKits/grrt/reqRouter.go:179.2,179.30 1 1
139+
github.com/GolangToolKits/grrt/reqRouter.go:182.49,186.2 3 1
140+
github.com/GolangToolKits/grrt/reqRouter.go:188.55,191.17 3 1
141+
github.com/GolangToolKits/grrt/reqRouter.go:191.17,193.17 2 1
142+
github.com/GolangToolKits/grrt/reqRouter.go:193.17,195.4 1 1
143+
github.com/GolangToolKits/grrt/reqRouter.go:197.2,197.12 1 1
144+
github.com/GolangToolKits/grrt/reqRouter.go:200.70,207.15 7 1
145+
github.com/GolangToolKits/grrt/reqRouter.go:207.15,209.12 1 1
146+
github.com/GolangToolKits/grrt/reqRouter.go:209.12,210.9 1 1
147+
github.com/GolangToolKits/grrt/reqRouter.go:212.3,213.17 2 1
148+
github.com/GolangToolKits/grrt/reqRouter.go:213.17,214.28 1 1
149+
github.com/GolangToolKits/grrt/reqRouter.go:214.28,215.28 1 1
150+
github.com/GolangToolKits/grrt/reqRouter.go:215.28,217.44 2 1
151+
github.com/GolangToolKits/grrt/reqRouter.go:217.44,220.12 3 1
152+
github.com/GolangToolKits/grrt/reqRouter.go:222.11,222.36 1 1
153+
github.com/GolangToolKits/grrt/reqRouter.go:222.36,225.11 3 1
154+
github.com/GolangToolKits/grrt/reqRouter.go:228.9,231.15 3 1
155+
github.com/GolangToolKits/grrt/reqRouter.go:231.15,233.5 1 1
156+
github.com/GolangToolKits/grrt/reqRouter.go:234.4,234.32 1 1
157+
github.com/GolangToolKits/grrt/reqRouter.go:237.2,237.19 1 1
158+
github.com/GolangToolKits/grrt/reqRouter.go:240.96,242.36 2 1
159+
github.com/GolangToolKits/grrt/reqRouter.go:242.36,243.32 1 1
160+
github.com/GolangToolKits/grrt/reqRouter.go:243.32,245.4 1 1
161+
github.com/GolangToolKits/grrt/reqRouter.go:247.2,248.27 2 1
162+
github.com/GolangToolKits/grrt/reqRouter.go:251.52,255.25 4 1
163+
github.com/GolangToolKits/grrt/reqRouter.go:255.25,257.15 2 1
164+
github.com/GolangToolKits/grrt/reqRouter.go:257.15,259.4 1 1
165+
github.com/GolangToolKits/grrt/reqRouter.go:261.2,261.12 1 1
166166
github.com/GolangToolKits/grrt/router.go:29.25,34.2 4 1
167167
github.com/GolangToolKits/grrt/router.go:37.46,39.49 2 1
168168
github.com/GolangToolKits/grrt/router.go:39.49,41.3 1 1

reqRouter.go

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ func (t *ReqRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4141
t.handleCors(w)
4242
} else {
4343
path := r.URL.Path
44-
// var rt = t.findPrefix(path)
4544
var rt Route
46-
// if rt == nil {
4745
sfile := t.isStaticFile(path)
4846
if !sfile {
4947
frt, fvars := t.findRouteAndVars(path)
@@ -53,19 +51,11 @@ func (t *ReqRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
5351
// rt = frt
5452
}
5553
}
56-
// frt, fvars := t.findRouteAndVars(path)
57-
// rt = frt
58-
// if rt != nil && len(*fvars) > 0 {
59-
// r = t.requestWithVars(r, rt.GetVarNames(), fvars)
60-
// // rt = frt
61-
// }
62-
// }
6354
if rt == nil && !sfile {
6455
rt = t.findPrefix(path)
6556
} else if rt == nil && sfile {
6657
rt = t.findFilePrefix(path)
6758
}
68-
// rt = t.findPrefix(path)
6959
if rt == nil || !rt.IsActive() {
7060
w.WriteHeader(http.StatusNotFound)
7161
} else if !rt.IsMethodAllowed(r.Method) {
@@ -207,71 +197,6 @@ func (t *ReqRouter) findFilePrefix(path string) Route {
207197
return rtn
208198
}
209199

210-
// func (t *ReqRouter) findRouteAndVars(path string) (Route, *[]string) {
211-
// var rnt Route
212-
// sp := strings.Split(path, "/")
213-
// var vars []string
214-
// // var vcnt = len(sp) - 2
215-
// var vl int
216-
// if len(sp) == 2 && sp[1] == "" {
217-
// vl = len(sp) - 2
218-
// } else {
219-
// vl = len(sp) - 1
220-
// }
221-
// var vcnt = vl
222-
// //log.Println("sp:", sp)
223-
// var found = false
224-
// var searchPath = ""
225-
// for i, p := range sp {
226-
// //if i == 0 {
227-
// //continue
228-
// if found {
229-
// break
230-
// }
231-
// // if i == 0 {
232-
// // continue
233-
// // } else if found {
234-
// // break
235-
// // }
236-
// // searchPath += "/" + p
237-
// if searchPath == "/" {
238-
// searchPath += p
239-
// } else {
240-
// searchPath += "/" + p
241-
// }
242-
// // searchPath += "/" + p
243-
// rts := t.namedRoutes[searchPath]
244-
// if rts != nil {
245-
// var baser = true
246-
// for _, rt := range *rts {
247-
// if rt.GetPath() != "/" {
248-
// baser = false
249-
// break
250-
// }
251-
// }
252-
253-
// for _, rt := range *rts {
254-
// if rt.GetPathVarsCount() == vcnt {
255-
// rnt = rt
256-
// found = true
257-
// vars = sp[i+1:]
258-
// if len(vars) == 1 && vars[0] == "" {
259-
// vars = []string{}
260-
// }
261-
// break
262-
// // } else if rt.GetPath() == "/" && !rt.IsPathVarsUsed() {
263-
// // } else if len(*rts) == 1 && rt.GetPath() == "/" && !rt.IsPathVarsUsed() {
264-
// } else if baser {
265-
// vcnt--
266-
// }
267-
// }
268-
// } else {
269-
// vcnt--
270-
// }
271-
// }
272-
// return rnt, &vars
273-
// }
274-
275200
func (t *ReqRouter) findRouteAndVars(path string) (Route, *[]string) {
276201
var rnt Route
277202
sp := strings.Split(path, "/")
@@ -326,7 +251,8 @@ func (t *ReqRouter) requestWithVars(r *http.Request, pVarNames, pvars *[]string)
326251
func (t *ReqRouter) isStaticFile(path string) bool {
327252
var rtn bool
328253
var ind = strings.LastIndex(path, ".")
329-
if ind > 0 {
254+
var ind2 = strings.LastIndex(path, "@")
255+
if ind > 0 && ind2 < 0 {
330256
disp := len(path) - (ind + 1)
331257
if disp < 4 {
332258
rtn = true

0 commit comments

Comments
 (0)