1
0
Fork
You've already forked feather
0
Feather is a lightweight modular HTTP framework for Go. It offers simple routing (static, dynamic, regex), global middleware, and a unified context for fast, extensible API and web app development.
  • Go 100%
2026年05月12日 21:10:28 +02:00
middlewares fix: Properly create Logger 2026年05月12日 21:10:28 +02:00
playground Fixed a little typo for dynamic routing 2025年09月11日 20:42:46 +02:00
.gitignore Initial commit 2026年04月28日 20:40:10 +02:00
context.go Fixed some bugs and added proper Logger 2026年05月11日 21:14:51 +02:00
feather.go fix: Properly create Logger 2026年05月12日 21:10:28 +02:00
go.mod Fixed some bugs and added proper Logger 2026年05月11日 21:14:51 +02:00
go.sum Added support for FS, HTTPS connection and two new middlewares, recover and requestId 2026年05月11日 20:44:59 +02:00
helper.go Fixed bug with logger 2026年05月12日 21:04:36 +02:00
LICENSE Create LICENSE 2025年09月10日 21:45:49 +02:00
README.md Fixed typo in README 2026年05月11日 21:18:36 +02:00
test.txt Added dynamic routing with regex and revised the way routes are stocked 2025年09月11日 20:25:10 +02:00

Feather

Feather is a lightweight, modular HTTP web framework for Go, designed for rapid development of RESTful APIs and web applications. It provides a simple routing system, middleware support, and convenient helpers for handling requests and responses.

Features

  • Routing: Register routes with static and dynamic segments, including custom regex for parameters.
  • Middleware: Add global middleware functions for logging, CORS, authentication, etc.
  • Context: Unified request/response context with helpers for JSON, HTML, files, headers, cookies, and more.
  • Extensible: Easily add custom middlewares and handlers.
  • Minimal Dependencies: Built on Go's standard library.

Getting Started

Installation

Add Feather to your Go project:

go get codeberg.org/esmyx/feather

Basic Usage

packagemainimport("codeberg.org/esmyx/feather""codeberg.org/esmyx/feather/middlewares")funcmain(){server:=feather.NewServer()// Add logging and CORS middlewareserver.AddMiddleware(middlewares.Logging(),middlewares.CORS([]string{"*"},[]string{"GET","POST","PUT","DELETE"},[]string{"Content-Type"},),)// Define routesserver.GET("/",func(c*feather.Context){c.String(200,"Welcome to Feather!")})server.GET("/user/:id|[0-9]+",func(c*feather.Context){userID:=c.Params["id"]c.JSON(200,map[string]string{"user_id":userID})})// Start serverserver.Listen(":8080")}

Routing

  • Static routes: /about
  • Dynamic routes: /user/:id
  • Dynamic with regex: /post/:slug|[a-z0-9\-]+
  • Wildcard: /files/*path

Middleware

Middlewares are functions that run before the route handler. Use AddMiddleware to register them globally.

Example: Logging and CORS are included in middlewares/.

Context Helpers

  • c.JSON(status, obj) – Send JSON response
  • c.String(status, text) – Send plain text
  • c.HTML(status, html) – Send HTML
  • c.File(status, path) – Send file
  • c.Status(status) – Send status code only
  • c.Redirect(status, url) – Redirect
  • c.SetHeader(key, value) – Set response header
  • c.SetCookie(cookie) – Set cookie
  • c.Query(key) – Get query param
  • c.JSONBody(v) – Parse JSON body
  • c.FormValue(key) – Get form value

License

GNU General Public License v3.0