blob: 3733b585ceeb92ef82bb0e993505787275a4f41f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package mooh
import (
"fmt"
"net/http"
)
func (self *Router) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
match, err := self.Match(req)
if err != nil {
fmt.Println(err)
fmt.Printf("oups")
return
}
if match == nil {
fmt.Fprint(resp, "Not Found")
return
}
request := NewRequest(req, match)
nresp, error := match.Route.Execute(request)
if error == nil {
fmt.Fprint(resp, nresp.Content)
} else {
fmt.Println(error)
}
}
|