repo_description: A Powerful HTTP API Gateway in pure golang！Goku API Gateway （中文名：悟空 API 网关）是一个基于 Golang开发的微服务网关，能够实现高性能 HTTP API 转发、服务编排、多租户管理、API 访问权限控制等目的，拥有强大的自定义插件系统可以自行扩展，并且提供友好的图形化配置界面，能够快速帮助企业进行 API 服务治理、提高 API 服务的稳定性和安全性。
repo_topics: api api-gateway gateway goku microservices middleware proxy
code: package main
  
  import (
  	"github.com/eolinker/goku-api-gateway/common/database"
  	"strconv"
  
  	"github.com/pkg/errors"
  
  	"github.com/eolinker/goku-api-gateway/common/conf"
  	"github.com/eolinker/goku-api-gateway/server/entity"
  )
  
  func getDefaultDatabase() (*entity.ClusterDB, error) {
  	dbType := conf.MastValue("db_type", "sqlite3")
  	switch dbType {
  	case database.MysqlDriver:
  		{
  			dbPort, err := strconv.Atoi(conf.MastValue("db_port", "3306"))
  			if err != nil {
  				return nil, err
  			}
  			return &entity.ClusterDB{
  				Driver:   dbType,
  				Host:     conf.Value("db_host"),
  				Port:     dbPort,
  				UserName: conf.Value("db_user"),
  				Password: conf.Value("db_password"),
  				Database: conf.Value("db_name"),
  			}, nil
  		}
  	case database.Sqlite3Driver:
  		{
  			return &entity.ClusterDB{
  				Driver: dbType,
  				Path:   conf.MastValue("db_path", "./work/goku.db"),
  			}, nil
  		}
  	default:
  		{
  			return nil, errors.New("unsupported database type")
  		}
  	}
  
  }
  