...

Command microservice

Command: microservice

Description: Micro Service

Usage: microservice

Example: ./config.json

```json

{
    "namespace": "api-registration",
    "server": {
        "port": 8080
    },
	"templates": [
		{
			"name": "registration",
			"path": "/",
			"file_path": "example/template.html"
		}
	],
    "apis": [
        {
            "name": "registration",
            "path": "/registration",
            "method": "POST",
            "content_type": "application/json",
            "response_type": "application/json",
            "callback": {
                "plugin": "plugin.so",
                "function": "Registration"
            },
            "params": [
                {
                    "name": "username",
                    "label": "Username",
                    "placeholder": "Enter Username",
                    "type": "username",
                    "validate": "username",
                    "required": true,
                    "min": 5,
                    "max": 32
                },
                {
                    "name": "fullname",
                    "label": "Full Name",
                    "placeholder": "Enter Full Name",
                    "type": "name",
                    "validate": "name",
                    "required": true,
                    "min": 5,
                    "max": 32
                },
                {
                    "name": "email",
                    "label": "Email Address",
                    "placeholder": "Enter Email Address",
                    "type": "email",
                    "required": true,
                    "min": 5,
                    "max": 32
                },
                {
                    "name": "password",
                    "label": "Password",
                    "placeholder": "Enter Password",
                    "type": "password",
                    "required": true,
                    "min": 8,
                    "max": 120
                },
                {
                    "name": "confirm_password",
                    "label": "Confirm Password",
                    "placeholder": "Enter Confirm Password",
                    "type": "password",
                    "required": true,
                    "min": 8,
                    "max": 120
                }
            ]
        },
        {
            "name": "verification",
            "path": "/verification/:id/:otp",
            "method": "GET",
            "content_type": "application/json",
            "response_type": "application/json",
            "callback": {
                "plugin": "plugin.so",
                "function": "Verification"
            },
            "url_params": [
                {
                    "name": "id",
                    "type": "textnumber",
                    "required": true
                },
                {
                    "name": "otp",
                    "type": "textnumber",
                    "required": true
                }
            ]
        }
    ]
}

```

Example: main.go

```go

package main

import (
  "fmt"

  "gitlab.hexacode.org/go-libs/hctypes"
  "gitlab.hexacode.org/go-libs/microservice/config"
)

func Registration(ctx *config.ConfigContext) (int, hctypes.Dict, *config.ReturnHTTP) {
  fmt.Println(ctx.Config.ToDict().ToColoredJson())
  fmt.Println(ctx.ConfigApi.ToDict().ToColoredJson())
  fmt.Println(ctx.URLParams.ToColoredJson())
  fmt.Println(ctx.Params.ToColoredJson())
  fmt.Println(ctx.Headers.ToColoredJson())

  return 200, hctypes.Dict{
    "id":  1,
    "otp": 123456,
  }, nil
}

func Verification(ctx *config.ConfigContext) (int, hctypes.Dict, *config.ReturnHTTP) {
  fmt.Println(ctx.Config.ToDict().ToColoredJson())
  fmt.Println(ctx.ConfigApi.ToDict().ToColoredJson())
  fmt.Println(ctx.URLParams.ToColoredJson())
  fmt.Println(ctx.Params.ToColoredJson())
  fmt.Println(ctx.Headers.ToColoredJson())

  return 200, hctypes.Dict{
    "success": true,
    "message": "OTP verified",
  }, nil
}

```

Subdirectories

Name Synopsis
..
config
example
validate