Gofr is an opinionated microservice development framework. Listed in CNCF Landscape.
Visit https://gofr.dev for more details and documentation.
Even though generic applications can be written using Gofr, our main focus is to simplify the development of microservices. We will focus ourselves towards deployment in kubernetes and aspire to provide out-of-the-box observability.
If you already have a go project with go module, you can get gofr by calling: go get gofr.dev
. Follow the instructions below, if you are starting afresh.
The latest version of go in your system should be installed. If you have not already done that, install it from here. This can be tested by opening a terminal and trying go version
. One should also be familiar with golang syntax. Official golang website has an excellent tour of go and is highly recommended.
Writing an API service using Gofr is very simple.
- In an empty folder, initialise your go module using:
go mod init test-service
. If you intend to push your code to github, it is recommended to name your module like this:go mod init github.com/{USERNAME}/{REPO}
- Create
main.go
file with following content:
package main
import "gofr.dev/pkg/gofr"
func main() {
app := gofr.New()
app.GET("/", func(ctx *gofr.Context) (interface{}, error) {
return "Hello World!", nil
})
app.Start()
}
- Get all the dependencies using
go get ./...
. It will download gofr along with every other package it requires. - Start the server:
go run main.go
It will start the server on default port 8000. If this port is already in use, you can override the default port by mentioning an environment variable like this:HTTP_PORT=9000 go run main.go
- Simple API syntax
- REST Standards by default
- Battle Tested at Enterprise Scale
- Configuration management
- Database state management using migrations
- Inbuilt Middlewares along with support for custom middlewares
- Error Management
- Inbuilt Datastore, File System, Pub/Sub
- gRPC support
- Chained timeout control
- Serve Static Files
- Websocket
- Support for Surge Protection
- Inbuilt Traces, Metrics and Logs
If you want to say thank you and/or support the active development of GoFr:
- Add a GitHub Star to the project.
- Write a review or tutorial on Medium, Dev.to or personal blog.
- Visit CONTRIBUTING for details on submitting patches and the contribution workflow.