/gem

a simple and fast web framework, for building restful or web application, it built on top of fasthttp.

Primary LanguageGoOtherNOASSERTION

Gem GoDoc Build Status Go Report Card Coverage Status Join the chat at https://gitter.im/go-gem/gem

Gem, a simple and fast web framework, it built top of fasthttp.

The API is currently unstable until the version v1.0.0 being released, see milestones for more details.

Install

go get github.com/go-gem/gem

Features

  • Graceful shutdown and restart
  • Listen multiple ports at single process
  • Leveled logger
  • High-performance and pretty router, very friendly to RESTful APIs
  • Sessions support
  • Various Middlewares:
    • JSON WEB TOKEN middleware
    • Compress middleware
    • Basic Auth middleware
    • Request Body Limit middleware
    • CSRF middleware
    • CORS middleware

Performance

Gem benchmark

I have sent a pull request, waiting for merging and rerunning the benchmark, see go-web-framework-benchmark for more information.

Example

Quick Start
package main

import (
	"log"

	"github.com/go-gem/gem"
)

func main() {
	log.Fatal(gem.ListenAndServe(":8080", func(c *gem.Context) {
        c.HTML(200, "Hello world.")
    }))
}

Run the code above, and then navigate to 127.0.0.1:8080.

Router

Semantic Versioning

Gem follows semantic versioning 2.0.0 managed through GitHub releases.

Support Us

  • ⭐ the project.
  • Spread the word.
  • Contribute to the project.

Contribute

We’re always looking for help, so if you would like to contribute, we’d love to have you!

Motivation

Just for figuring out the web framework's workflow, and try to design a simple and strong web framework.

Related Packages

  • tests - a tests package for fasthttp and Gem.
  • sessions - a sessions manager package for fasthttp.
  • log - a simple, leveled logging package.

FAQ

  1. What should I pay attention to?

    At present, Gem is incompatible with some APIs of fasthttp, the incompatible APIs following:

    • fasthttp.TimeoutHandler
  2. What is the difference between of fasthttp and gem?

    Gem built on top of fasthttp, and use Server.ServeConn to serve connections, it can not works without fasthttp.

    Advantages:

    Gem provides some useful built-in features, such as:

    • High-performance router
    • Leveled logger
    • Various middlewares
    • Sessions support
    • Graceful shutdown and restart

    Disadvantages:

    at present, Gem dose not provide APIs to Serve the custom Listener like fasthttp.Serve, but that will not be a problem, We will add support for this feature in the future.

LICENSE

MIT licensed. See LICENSE file for more information.

Inspiration & Credits

I have read the code of the following open source projects, and integrate their designs into this project.

I respect these projects and it's authors, and follow their LICENSE.

If your LICENSE is missing, please contact me, I will add it ASAP.