aisk / vox

Simple and lightweight Go web framework inspired by koa

Home Page:https://aisk.github.io/vox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VOX

Go Reference Build Status Codecov Go Report Card Maintainability Gitter chat

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

VoxLogo

Getting started

Installation

Using the go get power:

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

Basic Web Application

package main

import (
	"fmt"
	"time"

	"github.com/aisk/vox"
)

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

	// custom middleware that add a x-response-time to the response header
	app.Use(func(ctx *vox.Context, req *vox.Request, res *vox.Response) {
		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, res *vox.Response) {
		res.Body = "Hello, " + req.Params["name"] + "!"
	})

	app.Run("localhost:3000")
}

More Docs

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-2020 by aisk.

License

Vox is distributed by a MIT license.

About

Simple and lightweight Go web framework inspired by koa

https://aisk.github.io/vox/

License:MIT License


Languages

Language:Go 100.0%