Skip to content
Projets

À propos

Simple and lightweight Go web framework inspired by koa

Développement web et applicatif

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

VOX

Go Reference Build Status Codecov Go Report Card Maintainability Gitter chat

A Go web framework for humans, heavily inspired by Koa.

VoxLogo

Getting started

Installation

Requires Go 1.27 or later. Install with go get:

$ go get -u github.com/aisk/vox

Basic Web Application

package main

import (
	"fmt"
	"time"

	"github.com/aisk/vox"
)

type CreateUser struct {
	Name string `json:"name"`
}

type User struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func main() {
	app := vox.New()

	// custom middleware that adds an X-Response-Time header
	app.Use(func(ctx *vox.Context, req *vox.BaseRequest, res *vox.BaseResponse) {
		start := time.Now()
		ctx.Next()
		duration := time.Now().Sub(start)
		res.Header.Set("X-Response-Time", fmt.Sprintf("%s", duration))
	})

	// router param
	app.Get("/hello/{name}", func(ctx *vox.Context, req *vox.Request[vox.NoBody], res *vox.Response[string]) {
		res.Body = "Hello, " + req.Params["name"] + "!"
	})

	app.Post("/users", func(ctx *vox.Context, req *vox.Request[CreateUser], res *vox.Response[User]) {
		res.Status = 201
		res.Body = User{ID: 1, Name: req.Body.Name}
	})

	app.Run("localhost:3000")
}

Route handlers declare their request and response body types in the function signature. Vox decodes request bodies as JSON; use Request[vox.NoBody] when no decoding is needed. Middleware receives BaseRequest and BaseResponse.

Documentation

The full documentation lives at https://aisk.github.io/vox/.

Need Support?

If you need help for using vox, or have other questions, welcome to our gitter chat room.

About the Project

Vox is © 2016-2026 by aisk.

License

Vox is distributed by a MIT license.

Explorer des projets similaires

Chargement…