package middleware

import (
	"fmt"
	"log/slog"
	"slgserver/net"
)

func Log() net.MiddlewareFunc {
	return func(next net.HandlerFunc) net.HandlerFunc {
		return func(req *net.WsMsgReq, rsp *net.WsMsgRsp) {

		slog.Info("client req",
			"msgName", req.Body.Name,
			"data", fmt.Sprintf("%v", req.Body.Msg))

			next(req, rsp)
		}
	}
}