https://github.com/rookie-ninja/rk-boot
Build microservice with rk-boot and let the team take over clean and tidy code.
https://github.com/rookie-ninja/rk-boot
echo echo-middleware gin gin-middleware go go-project-structure golang gorilla-mux grpc grpc-middleware middleware
Last synced: 7 months ago
JSON representation
Build microservice with rk-boot and let the team take over clean and tidy code.
- Host: GitHub
- URL: https://github.com/rookie-ninja/rk-boot
- Owner: rookie-ninja
- License: apache-2.0
- Created: 2020-07-31T02:36:56.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-04T14:51:20.000Z (about 1 year ago)
- Last Synced: 2025-04-11T23:04:32.989Z (8 months ago)
- Topics: echo, echo-middleware, gin, gin-middleware, go, go-project-structure, golang, gorilla-mux, grpc, grpc-middleware, middleware
- Language: Go
- Homepage: https://rk.mofcloud.com
- Size: 7.13 MB
- Stars: 531
- Watchers: 8
- Forks: 58
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- go-awesome - rk-boot
- awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-plus - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily.  (Web Frameworks / Utility/Miscellaneous)
- fucking-awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- go-awesome - rk-boot
- awesome-go-cn - rk-boot - ninja/rk-boot) (Web框架 / 实用程序/Miscellaneous)
- awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-cn - rk-boot - ninja/rk-boot) (Web框架 / 实用程序/Miscellaneous)
- awesome-go - rookie-ninja/rk-boot - boot and let the team take over clean and tidy code. ☆`575` (Web Frameworks / Utility/Miscellaneous)
- awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-extra - rk-boot - boot and let the team take over clean and tidy code.|271|28|7|2020-07-31T02:36:56Z|2022-08-09T15:53:56Z| (Web Frameworks / Fail injection)
- awesome-go - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-with-stars - rk-boot - A bootstrapper library for building enterprise go microservice with Gin and gRPC quickly and easily. (Web Frameworks / Utility/Miscellaneous)
README
Build microservice with rk-boot and let the team take over clean and tidy code.
## Concept
rk-boot is a library which can manage backend service dependencies with YAML.
Standardize, unify and simplify microservice is huge challenge when project are getting bigger. Build microservice with rk-boot and let the team take over clean and tidy code.

## Quick Start
We will start [gin-gonic/gin](https://github.com/gin-gonic/gin) server with rk-boot.
### Install
```shell
go get github.com/rookie-ninja/rk-boot/v2
go get github.com/rookie-ninja/rk-gin/v2
```
### Code
boot.yaml
```yaml
---
gin:
- name: greeter # Required
port: 8080 # Required
enabled: true # Required
sw:
enabled: true # Optional, default: false
```
main.go
```go
// Copyright (c) 2021 rookie-ninja
//
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.
package main
import (
"context"
"fmt"
"github.com/gin-gonic/gin"
"github.com/rookie-ninja/rk-boot/v2"
"github.com/rookie-ninja/rk-gin/v2/boot"
"net/http"
)
// @title Swagger Example API
// @version 1.0
// @description This is a sample rk-demo server.
// @termsOfService http://swagger.io/terms/
// @securityDefinitions.basic BasicAuth
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
// Create a new boot instance.
boot := rkboot.NewBoot()
// Register handler
entry := rkgin.GetGinEntry("greeter")
entry.Router.GET("/v1/greeter", Greeter)
// Bootstrap
boot.Bootstrap(context.TODO())
boot.WaitForShutdownSig(context.TODO())
}
// Greeter handler
// @Summary Greeter
// @Id 1
// @Tags Hello
// @version 1.0
// @Param name query string true "name"
// @produce application/json
// @Success 200 {object} GreeterResponse
// @Router /v1/greeter [get]
func Greeter(ctx *gin.Context) {
ctx.JSON(http.StatusOK, &GreeterResponse{
Message: fmt.Sprintf("Hello %s!", ctx.Query("name")),
})
}
type GreeterResponse struct {
Message string
}
```
### Validate
Check API
```shell script
$ go run main.go
$ curl -X GET localhost:8080/v1/greeter?name=rk-dev
{"Message":"Hello rk-dev!"}
$ curl -X GET localhost:8080/rk/v1/ready
{
"ready": true
}
$ curl -X GET localhost:8080/rk/v1/alive
{
"alive": true
}
```
Check Swagger UI
Swagger UI: [http://localhost:8080/sw](http://localhost:8080/sw)

## Supported plugins
## Development Status: Stable
## Build instruction
Simply run make all to validate your changes. Or run codes in example/ folder.
- make all
If proto or files in boot/assets were modified, then we need to run it.
## Test instruction
Run unit test with **make test** command.
github workflow will automatically run unit test and golangci-lint for testing and lint validation.
## Contributing
We encourage and support an active, healthy community of contributors —
including you! Details are in the [contribution guide](CONTRIBUTING.md) and
the [code of conduct](CODE_OF_CONDUCT.md). The rk maintainers keep an eye on
issues and pull requests, but you can also report any negative conduct to
lark@rkdev.info.
## License
In compliance with open-source standards, this project is released and distributed under the terms of the [Apache 2.0 License](LICENSE)
## Join discussing channel
| Channel | Code |
|-------------------------|--------------------------------------------------|
| Wechat group (Chinese) |  |
| Slack channel (English) | [#rk-boot](https://rk-syz1767.slack.com/) |
## Star History
[](https://star-history.com/#rookie-ninja/rk-boot&Date)

