👋 Welcome!
🔥 Get Started
🔨 Create a Project
- Ensure you have Go installed.
- Create a project with
go mod init github.com/{user}/{repository}
- Install There with the
go get
command
go get -u github.com/Gebes/there/v2
- Create a
main.go
file
package main
import (
"github.com/Gebes/there/v2"
"github.com/Gebes/there/v2/status"
)
func main() {
router := there.NewRouter() // Create a new router
// Register GET route /
router.Get("/", func(request there.Request) there.Response {
return there.Json(status.OK, map[string]string{
"message": "Hello World!",
})
})
err := router.Listen(8080) // Start listening on 8080
if err != nil {
panic(err)
}
}
🤔 Why There?
The general problem with many routers is the way you handle responses. Most frameworks make it too complex or do not offer the proper abstraction to get the required result in a short amount of time.
The goal of There is to give developers the right tool to create robust apis in a shorter amount of time.
We solve this problem by providing simple interfaces to control the flow of your API.
Got an error while fetching the user? Just return Error(status, err)
. Want to return some data? Just return Json(status, data)
. Is the data too large? Compress it return Gzip(Json(status, data))
.
This type of control flow is way easier to read, and it doesn't take away any freedom!
⚡️ Speed
Speed is critical, even though your Go router will never be a bottleneck. As a comparison, There is faster than Gin and Mux (Benchmark, Result).
📤 Imports
If you create an API with There you do not need to import net/http
even once! Simply import
import "github.com/Gebes/there/v2"
and There provides you with all the handlers, constants and interfaces you need to create a router, middleware or anything else!
There provides enough constants for you! In total there are 140 of them.
- Method (
there.MethodGet
,there.MethodPost
) - Status (
status.OK
,statusInternalServerError
) - Header/Request only Header/Response only Header (
header.ContentType
,header.RequestAcceptEncoding
,header.ResponseLocation
) - ContentType (
there.ContentTypeApplicationJson
,there.ContentTypeApplicationXml
)
🧠 Philosophy
Focus on your project, not on the framework.
The goal of There is to save time and provide all the functionality a backend developer needs daily. Therefore, There should always keep it simple and only add complexity if there is no reasonable workaround.
New Go Developers often struggle with chores they are not used to, and There should help them make life easier.
From beginner to expert, There should be something for everyone.