Hi everyone! After weeks of development, I'm excited to officially launch Gofsen β a new web framework for building fast and maintainable REST APIs in Go.
π GitHub Repo
Bakemono-san
/
gofsen
A fast, idiomatic API framework for Go, built in Senegal.
π Gofsen - HTTP Framework for Go
Gofsen is a lightweight, Express.js-inspired HTTP framework for Go. Simple, fast, and powerful.
π¦ Installation
go get github.com/Bakemono-san/gofsen
π Quick Start
package main
import "github.com/Bakemono-san/gofsen"
func main() {
app := gofsen.New()
app.GET("/", func(c *gofsen.Context) {
c.JSON(map[string]string{
"message": "Hello Gofsen!",
"version": gofsen.Version,
})
})
app.Listen("8080")
}
β¨ Features
β HTTP Routing
- HTTP Methods: GET, POST, PUT, DELETE, PATCH
-
Route Parameters:
/users/:id -
Route Groups:
/api/v1 -
Query Parameters:
?name=value
β Middleware System
- Logger: Automatic request logging
- Recovery: Panic recovery
- CORS: Complete CORS support with configuration
- Custom Middleware: Create your own middlewares
β Request/Response Helpers
- JSON: Automatic parsing and sending
- Query Params: Easyβ¦
π§ Why Gofsen?
Gofsen was built out of a simple need: create clean, maintainable, and idiomatic APIs in Go β without boilerplate or over-engineered abstractions.
Other frameworks like Gin, Echo, or Fiber are great, but sometimes you just want:
- β Clear routing
- β Simple middleware chaining
- β
Route groups (
/api/v1) - β
Dynamic params (
/users/:id) - β JSON helpers and error handling
- β No reflection, no magic
That's where Gofsen shines.
β¨ Features
- β HTTP Routing: GET, POST, PUT, DELETE, PATCH
- β
Route Parameters:
/users/:id - β
Route Groups:
/api/v1, with local middleware - β Global & Custom Middleware
- β Request Helpers: JSON, query params, errors
- β Built-in Middleware: CORS, Logging, Recovery
- β Built in Go with β€οΈ from Senegal πΈπ³
π§ͺ Quick Start
Try it out right now! Here's a complete working example:
And here's the actual Gofsen Go code:
package main
import (
"github.com/Bakemono-san/gofsen"
)
func main() {
r := gofsen.New()
r.GET("/hello", func(ctx *gofsen.Context) {
ctx.Status(200).JSON(map[string]string{"message": "Hello from Gofsen"})
})
r.Listen("8080")
}
π Route Parameters & Groups
package main
import (
"github.com/Bakemono-san/gofsen"
)
func main() {
r := gofsen.New()
// Simple route with parameter
r.GET("/users/:id", func(ctx *gofsen.Context) {
userID := ctx.Param("id")
ctx.Status(200).JSON(map[string]string{
"user_id": userID,
"message": "User details",
})
})
// Route groups
api := r.Group("/api/v1")
api.GET("/posts", func(ctx *gofsen.Context) {
ctx.Status(200).JSON(map[string]string{"message": "All posts"})
})
api.POST("/posts", func(ctx *gofsen.Context) {
var post map[string]interface{}
if err := ctx.BindJSON(&post); err != nil {
ctx.Error(400, "Invalid JSON")
return
}
ctx.Status(201).JSON(map[string]interface{}{
"message": "Post created",
"post": post,
})
})
r.Listen("8080")
}
π§© Middleware Example
package main
import (
"github.com/Bakemono-san/gofsen"
)
// Custom Auth Middleware
func AuthMiddleware() gofsen.MiddlewareFunc {
return func(ctx *gofsen.Context) {
token := ctx.Request.Header.Get("Authorization")
if token != "Bearer valid-token" {
ctx.Error(401, "Unauthorized")
return
}
ctx.Next()
}
}
func main() {
r := gofsen.New()
// Global middleware
r.Use(gofsen.Logger())
r.Use(gofsen.Recovery())
r.Use(gofsen.CORS())
// Public routes
r.GET("/", func(ctx *gofsen.Context) {
ctx.Status(200).JSON(map[string]string{"message": "Welcome to Gofsen!"})
})
// Protected API group
api := r.Group("/api")
api.Use(AuthMiddleware()) // Apply auth to this group only
api.GET("/me", func(ctx *gofsen.Context) {
ctx.Status(200).JSON(map[string]string{
"user": "authenticated_user",
"message": "This is a protected route",
})
})
r.Listen("8080")
}
π Installation
go get github.com/Bakemono-san/gofsen
Import it in your project:
import "github.com/Bakemono-san/gofsen"
π§ Coming Soon
π οΈ A CLI is on the way to scaffold new Gofsen apps
gofsen new my-api
gofsen generate handler user
π Upcoming Features:Want to see the roadmap?
π Get Involved
Gofsen is 100% open-source and actively developed.
- π Report issues
- π Contribute features or fixes
- π’ Share it if you find it useful!
π https://github.com/Bakemono-san/gofsen
Thanks for reading, and happy hacking with Go! π¦«
Tags: #golang #go #api #webdev #opensource #framework #gofsen #backend #devtools
Top comments (2)
GOAT waiting for the next step
No worry buddy coming soon...