Skip to content
프로젝트

gomarten/marten has 98 GitHub stars and 6 forks. GitHot measured 0 in 7 days and 0 in 15 days. Last checked 2026-11-11 00:28 UTC. Last push 2026-06-11.

이 수치를 측정하는 방법

Elegant, minimalist Go web framework – nothing in the way.

What you can do

  • Zero Dependencies - Built entirely on Go's standard library
  • Fast Routing - Radix tree router with path parameters and wildcards
  • Middleware - Chainable middleware with 15 built-in options
  • Context Pooling - Efficient memory reuse for high throughput

측정된 스타 증가

in 24h
업데이트 지연
in 7 days
0
in 15 days
0
in 1 month
업데이트 지연

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Marten

A minimal, zero-dependency web framework for Go.

Go Reference Go Report Card CI License


Marten is a lightweight HTTP framework built entirely on Go's standard library. No external dependencies. No magic. Just clean, predictable code that gets out of your way.

Table of Contents

Installation

go get github.com/gomarten/marten

Quick Start

package main

import (
    "github.com/gomarten/marten"
    "github.com/gomarten/marten/middleware"
)

func main() {
    app := marten.New()
    
    app.Use(middleware.Logger)
    app.Use(middleware.Recover)

    app.GET("/", func(c *marten.Ctx) error {
        return c.OK(marten.M{"message": "Hello, World!"})
    })

    app.GET("/users/:id", func(c *marten.Ctx) error {
        id := c.ParamInt("id")
        return c.OK(marten.M{"id": id})
    })

    app.Run(":8080")
}

Features

Feature Description
Zero Dependencies Built entirely on Go's standard library
Fast Routing Radix tree router with path parameters and wildcards
Middleware Chainable middleware with 15 built-in options
Context Pooling Efficient memory reuse for high throughput
Response Helpers OK(), Created(), Accepted(), BadRequest(), NotFound(), and more
Typed Parameters ParamInt(), QueryInt(), QueryFloat64(), QueryBool()
Graceful Shutdown Built-in support via RunGraceful()

Routing

// Path parameters
app.GET("/users/:id", handler)
app.GET("/files/*filepath", handler)

// Route groups
api := app.Group("/api/v1")
api.GET("/users", listUsers)
api.POST("/users", createUser)

// All HTTP methods
app.GET("/resource", handler)
app.POST("/resource", handler)
app.PUT("/resource", handler)
app.DELETE("/resource", handler)
app.PATCH("/resource", handler)
app.HEAD("/resource", handler)
app.OPTIONS("/resource", handler)

Middleware

Built-in middleware:

import "github.com/gomarten/marten/middleware"

app.Use(middleware.Logger)           // Request logging
app.Use(middleware.Recover)          // Panic recovery
app.Use(middleware.CORS(config))     // Cross-origin requests
app.Use(middleware.RateLimit(cfg))   // Rate limiting
app.Use(middleware.BasicAuth(cfg))   // Basic authentication
app.Use(middleware.Timeout(5*time.Second))
app.Use(middleware.Compress(cfg))    // Gzip compression
app.Use(middleware.Secure(cfg))      // Security headers
app.Use(middleware.RequestID)        // Request ID injection
app.Use(middleware.BodyLimit(1*middleware.MB))
app.Use(middleware.ETag)             // ETag caching
app.Use(middleware.NoCache)          // Cache prevention
app.Use(middleware.Static("./public")) // Static file serving
app.Use(middleware.Health("/health")) // Health check endpoint

Route-specific middleware:

app.GET("/admin", adminHandler, authMiddleware, logMiddleware)

Context API

func handler(c *marten.Ctx) error {
    // Path and query parameters
    id := c.Param("id")
    page := c.QueryInt("page")
    price := c.QueryFloat64("price")  // float64 query param

    // Request data
    ip := c.ClientIP()
    token := c.Bearer()

    // JSON binding
    var user User
    if err := c.Bind(&user); err != nil {
        return c.BadRequest("invalid JSON")
    }

    // Context store (typed getters)
    score := c.GetFloat64("score")   // float64 store value

    // Responses
    return c.OK(data)              // 200
    return c.Created(data)         // 201
    return c.Accepted(data)        // 202  ← async / queued jobs
    return c.NoContent()           // 204
    return c.BadRequest("error")   // 400
    return c.NotFound("not found") // 404
}

Configuration

// Trailing slash handling
app.SetTrailingSlash(marten.TrailingSlashRedirect)

// Custom 404 handler
app.NotFound(func(c *marten.Ctx) error {
    return c.JSON(404, marten.E("page not found"))
})

// Custom error handler
app.OnError(func(c *marten.Ctx, err error) {
    c.JSON(500, marten.E(err.Error()))
})

// Graceful shutdown
app.RunGraceful(":8080", 10*time.Second)

// Debug: list all registered routes (sorted)
for _, r := range app.Routes() {
    fmt.Printf("%s %s\n", r.Method, r.Path)
}

Benchmarks

Marten performs competitively with Gin and Echo while maintaining zero dependencies.

Benchmark Marten Gin Echo Chi
Static Route 1,445 ns/op 1,323 ns/op 1,421 ns/op 2,208 ns/op
Param Route 1,536 ns/op 1,419 ns/op 1,474 ns/op 2,520 ns/op
JSON Response 1,651 ns/op 1,583 ns/op 1,754 ns/op 1,890 ns/op
JSON Binding 8,339 ns/op 8,634 ns/op 8,766 ns/op 6,810 ns/op
Multi-Param 1,841 ns/op 1,511 ns/op 1,634 ns/op 2,836 ns/op

Tested on Intel Xeon Platinum 8259CL @ 2.50GHz, Go 1.24, Linux

See benchmarks/ for full comparison with Gin, Echo, Chi and Fiber.

Examples

Example Description
basic Hello World, JSON, path and query params
crud-api RESTful API with validation
auth-jwt JWT authentication
middleware Built-in and custom middleware
groups Route groups and versioning
error-handling Custom error types and handlers
file-server Static files and SPA fallback
marten-demo Full web app with auth and templates

Documentation

Full documentation available at gomarten.github.io/docs

Contributing

See CONTRIBUTING.md for guidelines.

Community & Discussions

Questions or ideas?
Join the discussion: https://github.com/gomarten/marten/discussions

License

MIT License. See LICENSE for details.

관련 프로젝트 살펴보기