main function

Show/Hide Function Body
{
	metaFlag := flag.Bool("meta", false, "generate OpenAPI JSON and exit")
	flag.Parse()

	if *metaFlag {
		doc, err := swagger.Build("Example API", "1.0.0")
		if err != nil {
			fmt.Fprintf(os.Stderr, "swagger build error: %v\n", err)
			os.Exit(1)
		}
		fmt.Println(string(doc))
		os.Exit(0)
	}

	zapL, _ := zap.NewDevelopment()
	defer zapL.Sync()

	eng := http.NewFastHTTP()
	lg := &logger.Zap{L: zapL}

	router.New(
		registry.Global(),
		nil,
		eng,
		router.Options{
			SessionDuration: 24 * time.Hour,
			Logger:          lg,
		},
	)

	if err := eng.Serve(":8080"); err != nil {
		lg.Fatal("server terminated", "err", err)
	}
}

flag import

Import example:

import "flag"

fmt import

Import example:

import "fmt"

os import

Import example:

import "os"

time import

Import example:

import "time"

github.com/mirkobrombin/go-module-router/v1/http import

Import example:

import "github.com/mirkobrombin/go-module-router/v1/http"

github.com/mirkobrombin/go-module-router/v1/logger import

Import example:

import "github.com/mirkobrombin/go-module-router/v1/logger"

github.com/mirkobrombin/go-module-router/v1/registry import

Import example:

import "github.com/mirkobrombin/go-module-router/v1/registry"

github.com/mirkobrombin/go-module-router/v1/router import

Import example:

import "github.com/mirkobrombin/go-module-router/v1/router"

github.com/mirkobrombin/go-module-router/examples/v1/core/modules/ping import

Import example:

import "github.com/mirkobrombin/go-module-router/examples/v1/core/modules/ping"

Imported as:

Anonymous Import

github.com/mirkobrombin/go-module-router/examples/v1/core/swagger import

Import example:

import "github.com/mirkobrombin/go-module-router/examples/v1/core/swagger"

go.uber.org/zap import

Import example:

import "go.uber.org/zap"