Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysulq/doggy
Lightweight, idiomatic and stable for building Go 1.7+ HTTP services
https://github.com/sysulq/doggy
doggy golang http httprouter mux negroni web-framework
Last synced: 2 days ago
JSON representation
Lightweight, idiomatic and stable for building Go 1.7+ HTTP services
- Host: GitHub
- URL: https://github.com/sysulq/doggy
- Owner: sysulq
- License: mit
- Created: 2016-12-06T09:28:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-20T08:08:04.000Z (about 2 years ago)
- Last Synced: 2025-01-22T12:08:49.234Z (10 days ago)
- Topics: doggy, golang, http, httprouter, mux, negroni, web-framework
- Language: Go
- Homepage: https://hnlq715.github.io/doggy/
- Size: 21.7 MB
- Stars: 282
- Watchers: 36
- Forks: 66
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Doggy
===
[![Build Status](https://travis-ci.org/hnlq715/doggy.svg?branch=master)](https://travis-ci.org/hnlq715/doggy)
[![Go Report Card](https://goreportcard.com/badge/github.com/hnlq715/doggy)](https://goreportcard.com/report/github.com/hnlq715/doggy)Lightweight, idiomatic and stable for building Go 1.7+ HTTP services.
It aims to provide a composable way to develop HTTP services.dependency
---* [uber-go/zap](github.com/uber-go/zap)
* [gorilla/mux](github.com/gorilla/mux)
* [gorilla/schema](github.com/gorilla/schema)
* [urfave/negroni](github.com/urfave/negroni)
* [juju/ratelimit](github.com/juju/ratelimit)
* [unrolled/render](github.com/unrolled/render)
* [asaskevich/govalidator.v4](gopkg.in/asaskevich/govalidator.v4)
* [julienschmidt/httprouter](github.com/julienschmidt/httprouter)Generate api struct
---
* [himeraCoder/gojson](https://github.com/ChimeraCoder/gojson)
```
curl -s https://api.github.com/repos/chimeracoder/gojson | gojson -name=Repository -tags=schema,json
```Generate model package
---
* [hnlq715/xo](https://github.com/hnlq715/xo)
```
xo mysql://user:passwd@host:port/db -o . --template-path templates --ignore-fields updateTime
```Example
---
```
package mainimport (
"net/http"
"net/url"
"time""github.com/hnlq715/doggy"
"github.com/hnlq715/doggy/httpclient"
"github.com/hnlq715/doggy/middleware"
"github.com/hnlq715/doggy/render"
"github.com/prometheus/client_golang/prometheus/promhttp"
)func main() {
m := doggy.NewMux()
m.Handle("/metrics", promhttp.Handler())
m.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
processTime := 4 * time.Second
ctx := r.Context()
select {
case <-ctx.Done():
return
case <-time.After(processTime):
}
render.Text(w, 200, "pong")
})m.HandleFunc("/get", func(w http.ResponseWriter, r *http.Request) {
data := make(map[string]interface{})
u, _ := url.Parse("http://httpbin.org/get")
u.RawQuery = r.Form.Encode()
err := httpclient.Get(r.Context(), u.String()).ToJSON(&data)
if err != nil {
render.Text(w, 200, err.Error())
return
}
render.JSON(w, 200, data)
})n := doggy.Classic()
n.Use(middleware.NewPrometheus())
n.UseHandler(m)doggy.ListenAndServeGracefully(n)
}
```