You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"git.diulo.com/mogfee/kit"
|
|
|
|
"git.diulo.com/mogfee/kit/transport/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := kit.New(
|
|
|
|
kit.Name("user-server"),
|
|
|
|
kit.Server(appServer()))
|
|
|
|
fmt.Println("run start")
|
|
|
|
app.Run()
|
|
|
|
fmt.Println("run end")
|
|
|
|
app.Stop()
|
|
|
|
}
|
|
|
|
func appServer() *http.Server {
|
|
|
|
srv := http.NewServer(http.Address("localhost:9019"))
|
|
|
|
group := srv.Route("/")
|
|
|
|
group.Handle("GET", "/", func(ctx http.Context) error {
|
|
|
|
return errors.New("abc ")
|
|
|
|
})
|
|
|
|
//group.GET("/", func(ctx http.Context) error {
|
|
|
|
// return ctx.String(200, "index page")
|
|
|
|
//})
|
|
|
|
//group.GET("/hello", func(ctx http.Context) error {
|
|
|
|
// return ctx.String(200, "hello page")
|
|
|
|
//})
|
|
|
|
//group.GET("/error", func(ctx http.Context) error {
|
|
|
|
// fmt.Println("err 1")
|
|
|
|
// return errors.New(400, "BAD_REQUEST", "")
|
|
|
|
//})
|
|
|
|
return srv
|
|
|
|
}
|