Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Lightweight net/http 1.22+ enhancement library that combines the best of chi & Echo Enabling you to effortlessly write handlers using net/http

License

NotificationsYou must be signed in to change notification settings

aeilang/httpz

Repository files navigation

Logo

httpz v1.0.0 is release, its API is stable.

简体中文

httpz is not a new framework but rather an enhancement library for net/http. When you use httpz, you’re essentially working with the net/http standard library. Its goal is to address the usability gap in net/http 1.22, which, despite its improved routing capabilities, remains less convenient compared to frameworks like Echo and chi.

Key Features:

  • Built on net/http version 1.22+
  • Global error handling
  • Convenient grouping
  • Middleware adopted from chi
  • Data binding adopted from Echo
  • Easy response shortcuts

httpz is fully compatible with net/http. You can choose to leverage the enhanced features of httpz or stick to using plain net/http directly.

Quick Start

1.Installation

To install httpz, Go 1.22 or higher is required.

go get github.com/aeilang/httpz

2.Hello World

import ("net/http""github.com/aeilang/httpz""github.com/aeilang/httpz/middleware")funcmain() {// Create a new muxmux:=httpz.NewServeMux()// add logger middleware, it 's copy from chi/middlewaremux.Use(middleware.Logger)// register a GET /hello route// GET /hellomux.Get("/hello",func(w http.ResponseWriter,r*http.Request)error {returnhttpz.JSON(w,http.StatusOK,"hello httpz")// or// hw is a helper responsewriter to send response// hw := httpz.NewHelperRW(w)// return hw.String(http.StatusOK, "hello httpz")// or you can write it by yourself.// hw.Header().Set("Content-Type", "text/plain; charset=UTF-8")// hw.WriteHeader(http.StatusOK)// hw.Write([]byte("hello httpz"))// return nil})// just like net/http's ServerMuxhttp.ListenAndServe(":8080",mux)}

the middleware package is copied from chi/middleware.

The complete example can be found in the_example directory

Benchmark

Generated byGo web framework benchmark:

benchmark

For detailed benchmark results, please refer tobenchmark.

Feel free to contribute your code.

  • test

  • example

  • middleware

  • other

About

Lightweight net/http 1.22+ enhancement library that combines the best of chi & Echo Enabling you to effortlessly write handlers using net/http

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp