core

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 4 Imported by: 0

README

API Core

Based on common API stack, here is a list of enhanced packages to simplify your go (or 'golang') API development.

Contents

Getting started

  1. Download core by using:
    $ go get -u github.com/tossaro/go-api-core
  1. Add file .env on your main.go folder, see .env

  2. Import the following package:

    import "github.com/tossaro/go-api-core"
  1. Initial the config in main.go code:
    func main() {
        cfg, err := core.NewConfig()
        if err != nil {
            log.Fatal("Config error: %s", err)
        }
        //...
    }
  1. Add every package that you need for your API as example gin:
    g := gin.New(&gin.Options{
        Mode:         cfg.HTTP.Mode,
        Version:      cfg.App.Version,
        BaseUrl:      cfg.App.Name,
        Logger:       l,
        Redis:        rdb,
        AccessToken:  cfg.TOKEN.Access,
        RefreshToken: cfg.TOKEN.Refresh,
    })

Packages

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	App struct {
		Name    string
		Version string
	}

	Services []Service

	HTTP struct {
		Mode string
		Port string
	}

	Log struct {
		Level string
	}

	Redis struct {
		Url      string
		Password string
	}

	Postgre struct {
		Url     string
		PoolMax int
	}

	Twilio struct {
		SID        string
		Token      string
		ServiceSID string
	}

	TOKEN struct {
		Access  int
		Refresh int
	}
}

func NewConfig

func NewConfig() (Config, error)

type Service

type Service struct {
	Url  string
	Name string
}

Directories

Path Synopsis
docs
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL