ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - jvcoutinho/lit: A simple, fast and expressive HTTP framework for Go.
A simple, fast and expressive HTTP framework for Go. - jvcoutinho/lit
Visit Site

GitHub - jvcoutinho/lit: A simple, fast and expressive HTTP framework for Go.

GitHub - jvcoutinho/lit: A simple, fast and expressive HTTP framework for Go.

Go Reference Go Report Card codecov

Lit 🔥

Lit is an expressive and fast HTTP framework for Golang. It aims to enhance development by providing great simplicity, extensibility and maintainability.

Documentation

Check Lit documentation.

Getting started

Create a new Go project and import Lit with the command:

go get github.com/jvcoutinho/lit

Write this to your main.go file:

package main

import (
  "log"
  "net/http"

  "github.com/jvcoutinho/lit"
  "github.com/jvcoutinho/lit/render"
)

func main() {
  r := lit.NewRouter()
  r.Use(lit.Log)
  r.Use(lit.Recover)

  r.GET("/", HelloWorld)

  server := http.Server{Addr: ":8080", Handler: r}
  log.Fatalln(server.ListenAndServe())
}

func HelloWorld(r *lit.Request) lit.Response {
  return render.OK("Hello, World!")
}

Then you can start adding new routes and middlewares.

Features

  • Speed and efficiency: It uses httprouter, a very fast zero-allocation router. See benchmarks.
  • Expressiveness: Its constructs make room for declarative programming, creating code that is more readable, maintainable, extensible and testable.
  • Flexibility: It allows one to easily extend its constructs. Creating new validations, middlewares and responses, for example, is very simple and intuitive.
  • Idiomatic: It uses latest Go features, such as generics, in order to build a framework that is elegant to code.

Check an example of lit.Handler vs http.Handler.

Benchmarks

The instances below were tested with the specifications:

goos: windows
goarch: amd64
pkg: github.com/julienschmidt/go-http-routing-benchmark
cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz

You can check the methodology or try yourself with go-http-routing-benchmark.

GitHub API

Router Memory for handler registration Number repetitions Latency per repetition Heap memory per repetition Allocations per repetition
Chi 94888 B 10000 105680 ns/op 61713 B/op 406 allocs/op
Gin 94888 B 84152 14056 ns/op 0 B/op 0 allocs/op
Lit 🔥 42088 B 65989 17919 ns/op 0 B/op 0 allocs/op
Gorilla 1319632 B 612 1886488 ns/op 199684 B/op 1588 allocs/op
HttpRouter 37136 B 114933 10511 ns/op 0 B/op 0 allocs/op
Martini 485032 B 596 2070638 ns/op 231420 B/op 2731 allocs/op

Parse API

Router Memory for handler registration Number repetitions Latency per repetition Heap memory per repetition Allocations per repetition
Chi 9656 B 315666 11549 ns/op 7904 B/op 52 allocs/op
Gin 7864 B 3118021 1144 ns/op 0 B/op 0 allocs/op
Lit 🔥 5776 B 2670331 1342 ns/op 0 B/op 0 allocs/op
Gorilla 105448 B 75290 47507 ns/op 23632 B/op 198 allocs/op
HttpRouter 5072 B 4421617 816 ns/op 0 B/op 0 allocs/op
Martini 45808 B 45362 79979 ns/op 25696 B/op 305 allocs/op

Fake API (only static routes)

Router Memory for handler registration Number repetitions Latency per repetition Heap memory per repetition Allocations per repetition
Chi 83160 B 51685 69608 ns/op 47728 B/op 314 allocs/op
Gin 34344 B 385328 9302 ns/op 0 B/op 0 allocs/op
Lit 🔥 25560 B 450072 7944 ns/op 0 B/op 0 allocs/op
Gorilla 582536 B 7695 500949 ns/op 113042 B/op 1099 allocs/op
HttpRouter 21712 B 638422 5716 ns/op 0 B/op 0 allocs/op
Martini 309880 B 3915 916608 ns/op 129211 B/op 2031 allocs/op

As seen, Lit consumes less memory to register a batch of routes and has performance comparable to the top performers, such as Gin Gonic and HttpRouter.

Contributing

Feel free to open issues or pull requests!


Copyright (c) 2023-2024

João Victor de Sá Ferraz Coutinho [email protected]

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory