package compress

import (
	

	
)

// New creates a new middleware handler
func ( ...Config) fiber.Handler {
	// Set default config
	 := configDefault(...)

	// Setup request handlers
	var (
		       = func( *fasthttp.RequestCtx) {}
		 fasthttp.RequestHandler
	)

	// Setup compression algorithm
	switch .Level {
	case LevelDefault:
		// LevelDefault
		 = fasthttp.CompressHandlerBrotliLevel(,
			fasthttp.CompressBrotliDefaultCompression,
			fasthttp.CompressDefaultCompression,
		)
	case LevelBestSpeed:
		// LevelBestSpeed
		 = fasthttp.CompressHandlerBrotliLevel(,
			fasthttp.CompressBrotliBestSpeed,
			fasthttp.CompressBestSpeed,
		)
	case LevelBestCompression:
		// LevelBestCompression
		 = fasthttp.CompressHandlerBrotliLevel(,
			fasthttp.CompressBrotliBestCompression,
			fasthttp.CompressBestCompression,
		)
	default:
		// LevelDisabled
		return func( *fiber.Ctx) error {
			return .Next()
		}
	}

	// Return new handler
	return func( *fiber.Ctx) error {
		// Don't execute middleware if Next returns true
		if .Next != nil && .Next() {
			return .Next()
		}

		// Continue stack
		if  := .Next();  != nil {
			return 
		}

		// Compress response
		(.Context())

		// Return from handler
		return nil
	}
}