Skip to content
This repository
Browse code

Simpler way to check for Request type.

  • Loading branch information...
commit 524ee1ea01e7df5542137a309af68ceb7c8dccd5 1 parent f4f1b81
Peter H. Froehlich authored December 20, 2009

Showing 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. 8  web.go
8  web.go
@@ -14,6 +14,12 @@ import (
14 14
 
15 15
 type Request http.Request
16 16
 
  17
+var requestType reflect.Type
  18
+
  19
+func init() {
  20
+    var r Request
  21
+    requestType = reflect.Typeof(r)
  22
+}
17 23
 
18 24
 type route struct {
19 25
     r       string
@@ -69,7 +75,7 @@ func routeHandler(c *http.Conn, req *http.Request) {
69 75
                 ptyp, ok := a0.(*reflect.PtrType)
70 76
                 if ok {
71 77
                     typ := ptyp.Elem()
72  
-                    if typ.PkgPath() == "web" && typ.Name() == "Request" {
  78
+                    if typ == requestType {
73 79
                         req.ParseForm()
74 80
                         wr := (*Request)(req)
75 81
                         args[ai] = reflect.NewValue(wr)

0 notes on commit 524ee1e

Please sign in to comment.
Something went wrong with that request. Please try again.