Common Service

Enable common service for server.

Overview

Common service contains builtin API commonly used by user.

Path Description
/rk/v1/apis List APIs in current EchoEntry.
/rk/v1/certs List CertEntry.
/rk/v1/configs List ConfigEntry.
/rk/v1/deps List dependencies related application, entire contents of go.mod file would be returned.
/rk/v1/entries List all Entries.
/rk/v1/gc Trigger GC
/rk/v1/healthy Get application healthy status.
/rk/v1/info Get application and process info.
/rk/v1/license Get license related application, entire contents of LICENSE file would be returned.
/rk/v1/logs List logger related entries.
/rk/v1/git Get git information.
/rk/v1/readme Get contents of README file.
/rk/v1/req List prometheus metrics of requests.
/rk/v1/sys Get OS stat.
/rk/v1/tv Get HTML page of /tv.

Installation

go get github.com/rookie-ninja/rk-boot

General options

These are general options to start an echo server with rk-boot

name description type default value
echo.name The name of echo server string N/A
echo.port The port of echo server integer nil, server won’t start
echo.enabled Enable echo entry bool false
echo.description Description of echo entry. string ""

CommonService options

name description type default value
echo.commonService.enabled Enable embedded common service boolean false

Quick start

1.Create boot.yaml

---
echo:
  - name: greeter
    port: 8080
    enabled: true
    commonService:
      enabled: true     # Enable common service

2.Create main.go

package main

import (
	"context"
	"github.com/rookie-ninja/rk-boot"
)

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

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

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

3.Validate

$ curl -X GET localhost:8080/rk/v1/healthy
{"healthy":true}

Cheers

4.Enable swagger UI

In order to visualise common service in swagger UI, we need to enable swagger in boot.yaml as bellow.

---
echo:
  - name: greeter
    port: 8080
    enabled: true
    commonService:
      enabled: true     # Enable common service
    sw:
      enabled: true     # Enable swagger UI

Validate

http://localhost:8080/sw

sw-common

Cheers

Last modified November 2, 2021 : Add Echo framework documentation (80ec258)