README

gobase

godoc - documentation go report card codecov - code coverage github action - test

gobase is a web framework with basic settings and structure, wrapping echo.

Installation

go get github.com/cancue/gobase

Example

package main

import (
  "net/http"

  "github.com/labstack/echo/v4"

  "github.com/cancue/gobase"
  "github.com/cancue/gobase/config"
  "github.com/cancue/gobase/router"
)

func main() {
  gb := gobase.Server{
    Config: &config.Config{
      Stage: "local",
      YAML: map[string]interface{}{
        "name": "gobase-demo",
        "server": map[string]interface{}{
          "port": 8888,
          "timeout": map[string]interface{}{
            "read":  600,
            "write": 600,
          },
        },
      },
    },
    Router: func(s router.Server) {
      s.GET("/", func(ctx echo.Context) error {
        return ctx.String(http.StatusOK, "Hello, World!")
      })
    },
  }

  gb.Start()
}

Demo

gobase-demo

License

MIT

Expand ▾ Collapse ▴

Documentation

Overview

Package gobase is a web framework with basic settings and structure, wrapping labstack/echo.

Example:

package main

import (
	"net/http"

	"github.com/labstack/echo/v4"

	"github.com/cancue/gobase"
	"github.com/cancue/gobase/config"
	"github.com/cancue/gobase/router"
)

func main() {
	gb := gobase.Server{
		Config: &config.Config{
			Stage: "local",
			YAML: map[string]interface{}{
				"name": "gobase-demo",
				"server": map[string]interface{}{
					"port": 8888,
					"timeout": map[string]interface{}{
						"read":  600,
						"write": 600,
					},
				},
			},
		},
		Router: func(s router.Server) {
			s.GET("/", func(ctx echo.Context) error {
				return ctx.String(http.StatusOK, "Hello, World!")
			})
		},
	}

	gb.Start()
}

You may want to check out https://github.com/cancue/gobase-demo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Config       *config.Config
	Router       router.Router
	Logger       logger.Logger
	ErrorHandler func(err error, c echo.Context)
	Middlewares  []echo.MiddlewareFunc
	Echo         *echo.Echo
}

Server is main dish.

func (*Server) Set

func (gb *Server) Set(lenCaller int, rpath string)

Set sets server with config/${stage}.yaml.

func (*Server) Start

func (gb *Server) Start()

Start starts server.

Source Files

Directories

Path Synopsis
config Package config has weakness because of lenCaller.
db/pg
errors
http
logger
router
util
validator