server

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: MIT Imports: 4 Imported by: 0

README

Server

Source GoDoc Build Status codecov License

server package provide a common server http.

Requirements

Golang 1.12.4 or higher

download the package:

go get -u github.com/ymohl-cl/gopkg/server

environment variables:

export MYAPP_SSL_ENABLE="true"
export MYAPP_SSL_CERTIFICATE="path_to_certificats/cert.pem"
export MYAPP_SSL_KEY="path_to_key/key.pem"
export MYAPP_PORT="4242"

Usage

import "github.com/ymohl-cl/gopkg/server"

func main() {
    s, err := server.New("myapp")
    if err != nil {
        panic(err)
    }
    if err = s.Start(); err != nil {
        panic(err)
    }
}

Changelog

v1.0.0

Initial commit

  • server http with tls in option
  • implement ping default route
  • logs activity is on by default
  • tests and documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ping

func Ping(c echo.Context) error

Ping method http GET

Types

type Config

type Config struct {
	SSL  ssl    `split_words:"true" required:"true"`
	Port string `split_words:"true" required:"true"`
}

Config support to the server

func NewConfig

func NewConfig(appName string) (Config, error)

NewConfig parse the environment values to return a initialized configuration

type ModelPong

type ModelPong struct {
	Pong bool `json:"pong"`
}

ModelPong describe the response http to a ping method

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server component

func New

func New(appName string) (Server, error)

New server http

func (Server) Start

func (s Server) Start() error

Start run the server

func (Server) SubRouter

func (s Server) SubRouter(prefix string) *echo.Group

SubRouter return with the prefix path specified on parameter

Jump to

Keyboard shortcuts

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