Context: hard foo controller mapping for test purpose
This commit is contained in:
parent
33e9d1e613
commit
f076ebaa3a
@ -1,18 +1,36 @@
|
||||
package framework
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Core is the core struct of the framework
|
||||
type Core struct{}
|
||||
type Core struct {
|
||||
router map[string]ControllerHandler
|
||||
}
|
||||
|
||||
// NewCore initialize the Core.
|
||||
func NewCore() *Core {
|
||||
return &Core{}
|
||||
return &Core{router: map[string]ControllerHandler{}}
|
||||
}
|
||||
|
||||
// Get is a simple get router
|
||||
func (c *Core) Get(url string, handler ControllerHandler) {
|
||||
c.router[url] = handler
|
||||
}
|
||||
|
||||
// ServeHTTP implements the Handler interface
|
||||
func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO
|
||||
log.Println("Welcome to the Araneae framework")
|
||||
|
||||
ctx := NewContext(w, r)
|
||||
|
||||
// XXX: hard code foo handler for test purpose
|
||||
router := c.router["foo"]
|
||||
if router == nil {
|
||||
return
|
||||
}
|
||||
|
||||
_ = router(ctx)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user