Skip to content

Latest commit

 

History

61 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hono.go

Web framework based on Honojs in Golang.
Faster x1.5 than gin.

Hero

Installation

go get -u github.com/evex-dev/hono.go

Documentation is coming soon.

Support Local, Vercel, and more.

Example

Example 1 - Minimal

package main

import (
	"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

package main

import (
	"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("<b>Hello World 2</b>")
	}).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

package main

import (
	"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("<b>Hello World 2</b>")
	}).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

package handler
 
import (
  "net/http"

  ...
)
 
func Handler(w http.ResponseWriter, r *http.Request) {
  app.ServeHTTP(w, r)
}
``

About

Web framework based on Honojs in Golang.

Topics

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages