https://github.com/iamdanielyin/halo
A lightweight and flexible Go web framework
https://github.com/iamdanielyin/halo
framework go http middleware web
Last synced: over 1 year ago
JSON representation
A lightweight and flexible Go web framework
- Host: GitHub
- URL: https://github.com/iamdanielyin/halo
- Owner: iamdanielyin
- License: apache-2.0
- Created: 2018-06-20T10:31:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-27T10:53:01.000Z (almost 8 years ago)
- Last Synced: 2025-01-23T16:14:07.156Z (over 1 year ago)
- Topics: framework, go, http, middleware, web
- Language: Go
- Homepage: https://yinfxs.github.io/halo/
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Halo
A lightweight and flexible Go web framework
## Installation
```sh
go get github.com/yinfxs/halo
```
## Import
```go
import "github.com/yinfxs/halo"
```
## Usage
```go
package main
import (
"fmt"
"log"
"time"
"github.com/yinfxs/halo"
)
// Logger 日志中间件
func Logger(ctx *halo.Context) {
start := time.Now().Unix()
raw := ctx.R.URL.RawQuery
info := fmt.Sprintf("%s %s", ctx.R.Method, ctx.R.URL.Path)
if raw != "" {
info += "?" + raw
}
log.Printf("--> %v\n", info)
ctx.Next()
log.Printf("<-- %s %dms\n", info, start-time.Now().Unix())
}
func main() {
a := halo.New()
a.Use(Logger)
a.Run(":3000")
}
```
```sh
2018/06/27 18:47:30 Listen and serve on :3000
2018/06/27 18:47:33 --> GET /
2018/06/27 18:47:33 <-- GET / 0ms
2018/06/27 18:47:34 --> GET /favicon.ico
2018/06/27 18:47:34 <-- GET /favicon.ico 0ms
```
## Contributing
If you'd like to help out with the project. You can put up a Pull Request.