gobase

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 9 Imported by: 0

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

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 added in v0.2.0

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.

Directories

Path Synopsis
Package config has weakness because of lenCaller.
Package config has weakness because of lenCaller.
db
pg

Jump to

Keyboard shortcuts

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