Giter Site home page Giter Site logo

yee's Introduction

Yee

 

🦄 Web frameworks for Go, easier & faster.

This is a framework for learning purposes. Refer to the code for Echo and Gin

  • Faster HTTP router
  • Build RESTful APIs
  • Group APIs
  • Extensible middleware framework
  • Define middleware at root, group or route level
  • Data binding for URI Query, JSON, XML, Protocol Buffer3 and form payload
  • HTTP/2(H2C)/Http3(QUIC) support

Supported Go versions

Yee is available as a Go module. You need to use Go 1.13 +

Example

Quick start

	file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	
	if err != nil {
	    return
	}
	
	y := yee.New()
	
	y.SetLogLevel(logger.Warning)
	
	y.SetLogOut(file)
	 
	y.Use(Logger())
	 
 	y.Static("/assets", "dist/assets")

	y.GET("/", func(c yee.Context) (err error) {
		return c.HTMLTml(http.StatusOK, "dist/index.html")
	})

 	y.GET("/hello", func(c yee.Context) error {
		return c.String(http.StatusOK, "<h1>Hello Gee</h1>")
	})

	y.POST("/test", func(c yee.Context) (err error) {
		u := new(p)
		if err := c.Bind(u); err != nil {
			return c.JSON(http.StatusOK, err.Error())
		}
		return c.JSON(http.StatusOK, u.Test)
	})

        y.Run(":9000")

API

Provide GET POST PUT DELETE HEAD OPTIONS TRACE PATCH

    
  y := yee.New()
    
  y.GET("/someGet", handler)
  y.POST("/somePost", handler)
  y.PUT("/somePut", handler)
  y.DELETE("/someDelete", handler)
  y.PATCH("/somePatch", handler)
  y.HEAD("/someHead", handler)
  y.OPTIONS("/someOptions", handler)
    
  y.Run(":8000")
    

Restful

You can use Any & Restful method to implement your restful api

  • Any
  y := yee.New()
    
  y.Any("/any", handler)
    
  y.Run(":8000")

  // All request methods for the same URL use the same handler
  • Restful
  func userUpdate(c Context) (err error) {
  	return c.String(http.StatusOK, "updated")
  }
  
  func userFetch(c Context) (err error) {
  	return c.String(http.StatusOK, "get it")
  }
  
  func RestfulApi() yee.RestfulApi {
  	return RestfulApi{
  		Get:  userFetch,
  		Post: userUpdate,
  	}
  }
  
  y := New()
  
  y.Restful("/", testRestfulApi())
  
  y.Run(":8000")
 
// All request methods for the same URL use the different handler

 

Middleware

  • basic auth
  • cors
  • crfs
  • gzip
  • jwt
  • logger
  • rate limit
  • recovery
  • secure
  • request id

Benchmark

Resource

  • CPU: i7-9750H
  • Memory: 16G
  • OS: macOS 10.15.5

Date: 2020/06/17

License

MIT

yee's People

Contributors

cookiey avatar dependabot[bot] avatar

Stargazers

wangming avatar rere avatar rubbish avatar saintkay avatar Dean Zhang avatar Snow avatar Victor.D avatar  avatar Figure avatar Jhonny avatar jiaoningbo avatar agung susanto avatar Chen Zhidong avatar Bran avatar astrolemonade avatar ouyangbin avatar  avatar  avatar  avatar  avatar Ghostboy avatar Thompson avatar  avatar  avatar 慕容鼎 avatar  avatar Jay Chang avatar 呼噜噜 avatar Jumping Qu avatar 翟宇鑫 avatar  avatar  avatar wuqingyan avatar Ethan avatar pnnh avatar Nexpro avatar  avatar abel avatar Dolfly avatar robert avatar  avatar Basel Ajarmah avatar  avatar 郭伟匡 avatar zbv avatar  avatar 007 avatar zhanglizhu avatar  avatar w4v3 avatar  avatar  avatar Jason avatar alpha avatar adao avatar Phantom avatar yc avatar Yaguang Ding avatar 谁是谁的那谁呀 avatar 奇 avatar Jason Lee avatar ferris avatar  avatar  avatar SONGLIN YANG avatar  avatar  avatar  avatar

Watchers

Lucian avatar James Cloos avatar Carfield avatar  avatar 呼噜噜 avatar  avatar  avatar

yee's Issues

主进程的console日志如何保存到日志文件中,自己配置的日志文件,但是不知道在哪里可以统一捕捉。

Creator: Henry Yee
Run_start
2021-01-29 15:58:21.041223 | INFO | handle/general.go:64 | TestSqlInfo_a:work_id:5fb77681a6268f94651067ce:user:root:Host:172.30.7.150:Port:3307:DbName:inc_test:CloudId:5d9c2b02a1822c15b2b3e2c8:SqlFileList:[eip/workflow/93266b8c61fa11eba099525400cdf875/1.txt]
zerolog: could not write event: can't make directories for new logfile: mkdir /opt/appl/golang: permission denied
DefaultDbUser:sql_audit
2021-01-29 15:58:21.187310 | INFO | handle/util/file_convert_string.go:60 | sqlch.TaskGen:5fb77681a6268f94651067ce:contextjob_type:file:downloadurl:eip/workflow/93266b8c61fa11eba099525400cdf875/1.txt
zerolog: could not write event: can't make directories for new logfile: mkdir /opt/appl/golang: permission denied
Hey, I'm going to do some work
SubmitTask:downloadurl:eip/workflow/93266b8c61fa11eba099525400cdf875/1.txt:start2021-01-29 15:58:21.187487 | INFO | handle/util/file_convert_string.go:98 | SubmitTask:downloadurl:eip/workflow/93266b8c61fa11eba099525400cdf875/1.txt:start
zerolog: could not write event: can't make directories for new logfile: mkdir /opt/appl/golang: permission denied
2021-01-29 15:58:21.187635 | INFO | handle/util/file_convert_string.go:134 | SubmitTask:downloadurl:eip/workflow/93266b8c61fa11eba099525400cdf875/1.txt:send
zerolog: could not write event: can't make directories for new logfile: mkdir /opt/appl/golang: permission denied
2021-01-29 15:58:22.110334 | INFO | handle/util/file_convert_string.go:123 | SubmitTask%!(EXTRA string=Http Request is Send)
zerolog: could not write event: can't make directories for new logfile: mkdir /opt/appl/golang: permission denied
body select * from
panic: runtime error: index out of range [3] with length 1

goroutine 38 [running]:
sql-audit/handle/util.FileNameAndDbname(0xc0001b4040, 0x33, 0xc000092e38, 0x2, 0x2, 0x13, 0x0, 0x0)
/Users/ouyangbin/Documents/001_work/01_git/sql-audit/handle/util/file_convert_string.go:194 +0x182
sql-audit/handle/util.(*SqlContextHandle).SubmitTask(0xc0001ba070, 0x19e72e0, 0xc0001023c0, 0xc0002da1d0, 0x18ad50e, 0x4, 0x0, 0x0, 0xc0001b4040, 0x33, ...)
/Users/ouyangbin/Documents/001_work/01_git/sql-audit/handle/util/file_convert_string.go:180 +0xc01
created by sql-audit/handle/util.(*SqlContextHandle).WorkSendM
/Users/ouyangbin/Documents/001_work/01_git/sql-audit/handle/util/file_convert_string.go:87 +0x19c

Process finished with exit code 2

undefined: Logger

main.go

package main

import (
"net/http"
"fmt"
"github.com/cookieY/yee"     
_ "github.com/cookieY/yee/middleware"
_ "github.com/cookieY/yee/logger"    
)

 

func main(){

y := yee.New()
 y.Use(Logger())
 	y.Static("/assets", "dist/assets")

	y.GET("/", func(c yee.Context) (err error) {
            fmt.Println("request")
    	return c.HTMLTpl(http.StatusOK, "tpl/index.html")
	})
   y.Run(":9000")

}

go run main.go

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.