fxfiber

package module
v0.0.0-...-a3487a5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 7 Imported by: 0

README

HTTP Server Module

PkgGoDev goreport

Environment Variables

HOST (Default: localhost)
PORT (Default: 5000)

Getting Started

Provide a http.Handler for httpserver fx Module Simple usage using echo

package main

import (
	"net/http"

	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	"go.uber.org/fx"

	"github.com/lucaskatayama/fx-contrib/httpserver"
)

func router() http.Handler {
	e := echo.New()
	e.Pre(middleware.RemoveTrailingSlash())

	e.Use(middleware.Logger())
	e.Use(middleware.Gzip())

	g := e.Group("/api")

	g.GET("/hello", func(c echo.Context) error {
		return c.String(http.StatusOK, "Hello World!")
	})
	return e
}

func main() {
	app := fx.New(
		httpserver.Module,
		fx.Provide(router),
	)
	app.Run()
}

HealthCheck Module

Environment Variables

HEALTHCHECK_HEALTHZ_PATH (Default: /healthz)
HEALTHCHECK_READINESS_PATH (Default: /readiness)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"fiber",
	fx.Provide(new),
	fx.Invoke(lifecycle),
)

Module provides a fx module

Use on fx app declation

app := fx.New(
   httpserver.Module,
)
View Source
var ModuleHealthCheck = fx.Module(
	"healthcheck",
	fx.Provide(newHealthCheck),
)

ModuleHealthCheck provides a healthcheck module for fx.

Functions

This section is empty.

Types

type FiberServer

type FiberServer *fiber.App

Jump to

Keyboard shortcuts

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