31 lines
597 B
Go
31 lines
597 B
Go
//go:build example
|
|
// +build example
|
|
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"git.toowon.com/jimmy/go-common/factory"
|
|
commonhttp "git.toowon.com/jimmy/go-common/http"
|
|
)
|
|
|
|
func main() {
|
|
if err := factory.Init("config.json"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
app := factory.Default()
|
|
chain := app.MiddlewareChain()
|
|
|
|
http.Handle("/api/hello", chain.ThenFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
h := commonhttp.NewHandler(w, r)
|
|
h.Success(map[string]any{
|
|
"message": "Hello, World!",
|
|
"timezone": h.GetTimezone(),
|
|
})
|
|
}))
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
}
|