Repository navigation
Getting Started
Thanatat Tamtan edited this page Jun 9, 2026
·
9 revisions
Hime web server can start very easily 😀
package main
import (
"log"
"github.com/moonrhythm/hime"
)
func main() {
app := hime.New()
app.Address(":8080")
err := app.ListenAndServe()
if err != nil {
log.Fatal(err)
}
}Above code will start a web server using http.DefaultServeMux as handler at address :8080
package main
import (
"log"
"net/http"
"github.com/moonrhythm/hime"
)
func main() {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, Hime!"))
})
app := hime.New()
app.Handler(h)
app.Address(":8080")
err := app.ListenAndServe()
if err != nil {
log.Fatal(err)
}
}Above code sets h as the handler
You can use net/http handler to work with hime like the above example.
But if you want to use hime.Handler for your handler you can use hime.Handler to wrap
hime-style handler into http.Handler
package main
import (
"log"
"github.com/moonrhythm/hime"
)
func main() {
h := hime.Handler(func(ctx *hime.Context) error {
return ctx.String("Hello, Hime!")
})
app := hime.New()
app.Handler(h)
app.Address(":8080")
err := app.ListenAndServe()
if err != nil {
log.Fatal(err)
}
}app.Clone() returns a copy with the same server settings, routes, globals,
templates, and cookie signer — handy for deriving per-host or per-environment
variants from a shared base.
Next, see how to use Router