Giter Club home page Giter Club logo

doggy's Introduction

Doggy

Build Status Go Report Card

Lightweight, idiomatic and stable for building Go 1.7+ HTTP services. It aims to provide a composable way to develop HTTP services.

dependency

Generate api struct

curl -s https://api.github.com/repos/chimeracoder/gojson | gojson -name=Repository -tags=schema,json

Generate model package

xo mysql://user:passwd@host:port/db -o . --template-path templates --ignore-fields updateTime

Example

package main

import (
	"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)
}

doggy's People

Contributors

renovate[bot] avatar sysulq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doggy's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

gomod
go.mod
  • go 1.18
  • github.com/gorilla/mux v1.8.0
  • github.com/gorilla/schema v1.2.0
  • github.com/juju/ratelimit v1.0.2
  • github.com/julienschmidt/httprouter v1.3.0
  • github.com/prometheus/client_golang v1.12.2
  • github.com/spf13/viper v1.12.0
  • github.com/stretchr/testify v1.8.0
  • github.com/unrolled/render v1.5.0
  • github.com/urfave/negroni v1.0.0
  • go.uber.org/zap v1.23.0
  • gopkg.in/asaskevich/govalidator.v11 v11.0.1
  • gopkg.in/natefinch/lumberjack.v2 v2.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.