server: start with routing / request handling
This commit is contained in:
parent
064fe2c7a6
commit
e2afdeb61a
1 changed files with 17 additions and 1 deletions
|
@ -11,9 +11,23 @@ import (
|
||||||
|
|
||||||
type Cfg struct {
|
type Cfg struct {
|
||||||
*config.BaseCfg
|
*config.BaseCfg
|
||||||
Port string
|
Port string
|
||||||
|
Routes []RouteCfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RouteCfg struct {
|
||||||
|
Method string
|
||||||
|
Path string
|
||||||
|
Handler Handler
|
||||||
|
}
|
||||||
|
|
||||||
|
type FSCfg struct {
|
||||||
|
RouteCfg
|
||||||
|
DocRoot string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Handler func(lib.Context, *gin.Context)
|
||||||
|
|
||||||
type ServerState struct {
|
type ServerState struct {
|
||||||
server *http.Server
|
server *http.Server
|
||||||
}
|
}
|
||||||
|
@ -49,3 +63,5 @@ func Serve(ctx lib.Context) {
|
||||||
srv.ListenAndServe()
|
srv.ListenAndServe()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// route handlers
|
||||||
|
|
Loading…
Add table
Reference in a new issue