<commit_before>// Session Middleware
//
// In order to get session.

package sessionmiddleware

import (
	"github.com/headwindfly/clevergo"
)

var (
	// SessionName is the default session name.
	SessionName = "GOSESSION"
)

// SessionMiddleware
type SessionMiddleware struct {
	name string // Session name
}

// Returns SessionMiddleware instance.
func NewSessionMiddleware(name string) SessionMiddleware {
	return SessionMiddleware{
		name: name,
	}
}

// SessionMiddleware Handler.
//
// Implemented Middleware Interface.
func (m SessionMiddleware) Handle(next clevergo.Handler) clevergo.Handler {
	return clevergo.HandlerFunc(func(ctx *clevergo.Context) {
		ctx.Session, _ = ctx.SessionStore().Get(ctx.RequestCtx, m.name)
		defer ctx.Session.Save(ctx.RequestCtx)

		next.Handle(ctx)
	})
}<commit_msg>Added comments for GO Report<commit_after>// Session Middleware
//
// In order to get session.

package sessionmiddleware

import (
	"github.com/headwindfly/clevergo"
)

var (
	// SessionName default session name.
	SessionName = "GOSESSION"
)

// SessionMiddleware
//
// This middleware in order to get session.
type SessionMiddleware struct {
	name string // Session name
}

// NewSessionMiddleware returns Session Middleware instance.
func NewSessionMiddleware(name string) SessionMiddleware {
	return SessionMiddleware{
		name: name,
	}
}

// Handle implemented Middleware Interface.
func (m SessionMiddleware) Handle(next clevergo.Handler) clevergo.Handler {
	return clevergo.HandlerFunc(func(ctx *clevergo.Context) {
		ctx.Session, _ = ctx.SessionStore().Get(ctx.RequestCtx, m.name)
		defer ctx.Session.Save(ctx.RequestCtx)

		next.Handle(ctx)
	})
}
{'fraction_non_alphanumeric': 0.10500905250452625, 'fraction_numerical': 0.0, 'mean_word_length': 4.400651465798045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4307888', 'n_tokens_mistral': 505, 'n_tokens_neox': 511, 'n_words': 130}