introduce

As a complete example, embed a Web UI in the Echo framework to get service meta-information.

The name of the details
README The readme. md file is displayed if it is locally available
Process information Display Process Information
The API list Get API list
Entry list Please refer to the list of entriesdetails
The Config list List the Config file information
CA certificate | Lists TLS/SSL certificate information
Rely on List go.mod information
LICENSE If a local LICENSE file exists, it is displayed
OS information Current OS Information
Go Env information Go Environment Information
Git information If it is a Git project, it will be displayed
The Log information Display original Log information
Metrics Show the Prometheus Metrics

We will use RK-boot to start the Echo service.

Please visit the following address for the full tutorial:

  • rkdocs.netlify.app/cn

The installation

go get github.com/rookie-ninja/rk-boot
go get github.com/rookie-ninja/rk-echo
Copy the code

Quick start

For a complete demonstration, we use a Git project and add apis.

1. Create the boot. Yaml

In addition to turning on echo.tv.enabled, we also turned on other services so that we could verify the full TV page.

Refer to the other articles in this column for details on each option.

Or visit: rK-boot official documentation.

---
echo:
  - name: greeter                   # Required
    port: 8080                      # Required
    enabled: true                   # Required
    commonService:
      enabled: true                 # Optional, enable common service
    tv:
      enabled: true                 # Optional, enable TV
    sw:
      enabled: true                 # Optional, enable swagger UI
    interceptors:
      metricsProm:
        enabled: true
Copy the code

2. Create a main. 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"
	"github.com/rookie-ninja/rk-boot"
        _ "github.com/rookie-ninja/rk-echo/boot"
)

// Application entrance.
func main(a) {
	// Create a new boot instance.
	boot := rkboot.NewBoot()

	// Bootstrap
	boot.Bootstrap(context.Background())

	// Wait for shutdown sig
	boot.WaitForShutdownSig(context.Background())
}
Copy the code

3. Folder structure

. ├ ─ ─ LICENSE ├ ─ ─ the README. Md ├ ─ ─ the boot. The yaml ├ ─ ─. Mod ├ ─ ─. Sum └ ─ ─ main. GoCopy the code

4. Verify

$ go run main.go
Copy the code

Access localhost: 8080 / fairly rk/v1 / TV

4.1 the README

Rk-boot reads the local readme. md file and displays it on the TV page.

In the case of packaged compilation, rk-boot will look for.rk/ readme. md. You can use the Rk command line to facilitate compilation. Please refer to: examples

4.2 Process Meta Information

Rk-boot reads the local process information.

4.3 the API list

Rk-boot reads the list of all apis in Echo.

4.4 Entry list

4.5 the Config list

If boot.yaml has a config entry, it will be shown here.

The figure below is just a sample screenshot. The code above will not have Config because we did not add Config.

4.6 the certificate

If boot.yaml has a cert entry, it will be displayed here.

The following figure is just an example screenshot, the above code will not have Cert, because we did not add Cert.

4.7 depend on

Rk-boot will read the local go.mod file and display it on the TV page.

In the case of package compilation, rk-boot will find the.rk/go.mod path, you can use the Rk command line to facilitate compilation. Please refer to: examples

4.8 OS information

Rk-boot collects local OS information.

4.9 Go Env information

Rk-boot collects local Go Env information.

4.10 the Git information

Rk-boot reads the local.git file and displays it in the TV page.

Rk-boot will look for the.rk/rk.yaml path, which contains git information, if it is packaged and compiled. RK command line, easy to compile. Please refer to: examples

4.11 the Log information

Rk-boot displays information about all Log instances in the process.

4.12 Prometheus Metrics

Rk-boot If Prometheus middleware is enabled, basic monitoring information for the API can be seen in this page.