https://github.com/evex-dev/hono.go
Web framework based on Honojs in Golang.
https://github.com/evex-dev/hono.go
golang hono honogo honojs web-framework
Last synced: 2 months ago
JSON representation
Web framework based on Honojs in Golang.
- Host: GitHub
- URL: https://github.com/evex-dev/hono.go
- Owner: evex-dev
- License: mit
- Created: 2024-06-26T06:30:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-15T10:32:34.000Z (11 months ago)
- Last Synced: 2025-03-30T17:44:43.214Z (3 months ago)
- Topics: golang, hono, honogo, honojs, web-framework
- Language: Go
- Homepage: https://hono.go.evex.land
- Size: 89.8 KB
- Stars: 22
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hono.go
Web framework based on Honojs in Golang.
Faster x1.5 than gin.
## Installation
```sh
go get -u github.com/evex-dev/hono.go
```Documentation is coming soon.
Support Local, Vercel, and more.
## Example
### Example 1 - Minimal
```go
package mainimport (
"github.com/evex-dev/hono.go/src/context"
"github.com/evex-dev/hono.go/src/server"
)func main() {
app := server.Create()app.GET("/", func(c *context.Context) {
c.Status(200)
c.WriteString("Hello World")
})app.Init().Fire()
}
```### Example 2 - Options
```go
package mainimport (
"fmt""github.com/evex-dev/hono.go/src/context"
"github.com/evex-dev/hono.go/src/server"
)func main() {
app := server.Create()app.Use("/*", func(c *context.Context) {
fmt.Println("Catch Request on", c.URL().Path)
c.Next()
})app.Get("/", func(c *context.Context) {
c.Status(200)
c.Text("Hello World")
}).Get("/2", func(c *context.Context) {
c.Status(200).Html("Hello World 2")
}).Post("/3", func(c *context.Context) {
c.Status(200).Body([]byte("Hello World 3")).End()
})app.Init().SetHost("localhost").SetPort("3000").Callback(func(addr string, err error) error {
fmt.Printf("Listening on http://%s\n", addr)
return err
}).Fire()
}
```### Example 3 - Middleware
```go
package mainimport (
"fmt""github.com/evex-dev/hono.go/src/context"
"github.com/evex-dev/hono.go/src/middleware"
"github.com/evex-dev/hono.go/src/server"
)func main() {
app := server.Create()app.Use("/*", func(c *context.Context) {
fmt.Println("Catch Request on", c.URL().Path)
c.Next()
}).Use("/*", middleware.PoweredBy())app.Get("/", func(c *context.Context) {
c.Status(200)
c.Text("Hello World")
}).Get("/2", func(c *context.Context) {
c.Status(200).Html("Hello World 2")
}).Post("/3", func(c *context.Context) {
c.Status(200).Body([]byte("Hello World 3")).End()
})app.Init().SetHost("localhost").SetPort("3000").Callback(func(addr string, err error) error {
fmt.Printf("Listening on http://%s\n", addr)
return err
}).Fire()
}
```### Example 4 - Vercel
```go
package handler
import (
"net/http"...
)
func Handler(w http.ResponseWriter, r *http.Request) {
app.ServeHTTP(w, r)
}
``