Giter VIP home page Giter VIP logo

gas's Introduction

Gas

go-gas

Build Status codecov Go Report Card

Gas is a Web framework written in Go. And this is not a total complete project.

I just did a minimum workable architechture.

The workable feature is:

  • Router (based on fasthttprouter package)
  • Context (It can easy to render view and print json string)
  • Middleware
  • Logger middleware
  • Log package
  • Read config from a yaml file

And Model is not complete yet. Just finished MySQL sql Builder

all feature you can see in gas-example.

Install

$ go get github.com/go-gas/gas

Run demo

$ git clone https://github.com/go-gas/example.git && cd example
$ go run main.go

Your project file structure

|-- $GOPATH
|   |-- src
|       |--Your_Project_Name
|          |-- config
|              |-- default.yaml
|          |-- controllers
|              |-- default.go
|          |-- log
|          |-- models
|          |-- routers
|              |-- routers.go
|          |-- static
|          |-- views
|          |-- main.go

Quick start

Import

import (
    "Your_Project_Name/routers"
    "github.com/go-gas/gas"
    "github.com/go-gas/gas/middleware"
)

New

g := gas.New() // will load "config/default.yaml"

or

g := gas.New("config/path")

Register Routes

routers.RegistRout(g.Router)

Then in your routers.go

package routers

import (
    "Your_Project_Name/controllers"
    "github.com/go-gas/gas"
)

func RegistRout(r *gas.Router)  {

    r.Get("/", controllers.IndexPage)
    r.Post("/post/:param", controllers.PostTest)

    rc := &controllers.RestController{}
    r.REST("/User", rc)

}

Register middleware

g.Router.Use(middleware.LogMiddleware)

And you can write your own middleware function

func LogMiddleware(next gas.CHandler) gas.CHandler {
    return func (c *gas.Context) error  {

       // do something before next handler

       err := next(c)

       // do something after next handler

       return err
    }
}

And done

g.Run()

Benchmark

Using go-web-framework-benchmark to benchmark with another web fframework.

go-gas-benchmark

Benchmark-alloc

go-gas-benchmark-alloc

Benchmark-latency

go-gas-benchmark-latency

Benchmark-pipeline

go-gas-benchmark-pipeline

Concurrency

go-gas-concurrency

Concurrency-alloc

go-gas-concurrency-alloc

Concurrency-latency

go-gas-concurrency-latency

Concurrency-pipeline

go-gas-concurrency-pipeline

Benchmark conclusion

Iris is still the fastest web framework.

But gas is very new, so in the future

I wish this framework might not be a fastest but it will very fast and full featured.

Roadmap

  • Models
  • Model fields mapping
  • ORM
  • Relation mapping
  • Transaction
  • QueryBuilder
  • Session
  • Filesystem
  • Database
  • Redis
  • Memcache
  • Cache
  • Memory
  • File
  • Redis
  • Memcache
  • i18n
  • HTTPS
  • Command line tools
  • Form handler (maybe next version)
  • Security check features(csrf, xss filter...etc)

gas's People

Contributors

appleboy avatar gosilent avatar

Watchers

 avatar

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.