Categorygithub.com/sse-open/slog-echo
modulepackage
0.0.3
Repository: https://github.com/sse-open/slog-echo.git
Documentation: pkg.go.dev

# README

slog-echo

Simple echo middleware to log http requests using slog.

Usage

package main

import (
	"log/slog"
	"net/http"
	"os"

	"github.com/labstack/echo/v4"
	slogecho "github.com/sse-open/slog-echo"
)

func main() {
	e := echo.New()

	logger := slog.New(slog.NewTextHandler(os.Stdout, nil))

	e.Use(slogecho.New(logger).
		WithFilter(slogecho.IgnorePath("/healthcheck")).
		EchoMiddleware())

	e.GET("/healthcheck", func(c echo.Context) error {
		return c.String(http.StatusOK, "I'm aliver!")
	})

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

	e.Logger.Fatal(e.Start(":5000"))
}

License notices

MIT License. Copyright (c) 2024 Star Stable Entertainment AB

Parts of this code was forked and/or inspired by https://github.com/samber/slog-echo ( MIT License. Copyright (c) 2023 Samuel Berthe )

# Functions

Basic.
Host.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Method.
Path.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Status.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author