123456789101112131415161718192021222324252627282930313233 |
- package ss
- // The type implements the entry point
- // for all the request for the server.
- type RootRouter struct {
- handler Handler
- }
- // Return the new RootRouter with the specified
- // handler.
- func Root(handler Handler) *RootRouter {
- if handler == nil {
- panic("the root handler is nil")
- }
- ret := &RootRouter{}
- ret.handler = handler
- return ret
- }
- // Implementing the http.Handler .
- func (router *RootRouter) ServeHTTP(w ResponseWriter, r *Request) {
- ctx := Context{}
- ctx.W = w
- ctx.R = r
- u := *r.URL
- ctx.RelUrl = &u
- router.handler.Handle(&ctx)
- }
- func (router *RootRouter) Handle(c *Context) {
- router.handler.Handle(c)
- }
|