Skip to content

Add StartConfig.Listener so server with custom Listener is easier to create#2920

Merged
aldas merged 1 commit intolabstack:masterfrom
aldas:start_config_listener
Mar 19, 2026
Merged

Add StartConfig.Listener so server with custom Listener is easier to create#2920
aldas merged 1 commit intolabstack:masterfrom
aldas:start_config_listener

Conversation

@aldas
Copy link
Contributor

@aldas aldas commented Mar 19, 2026

Add StartConfig.Listener so server with custom Listener is easier to create

relates to #2918 (comment)
#1942

Example:

package main

import (
	"context"
	"net"
	"os"
	"os/signal"
	"syscall"
	"time"

	"github.com/labstack/echo/v5"
)

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

	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer cancel()

	lc := net.ListenConfig{
		KeepAlive: 15 * time.Second,
		//Control:   nil,
		//KeepAliveConfig: net.KeepAliveConfig{
		//	Enable:   false,
		//	Idle:     0,
		//	Interval: 0,
		//	Count:    0,
		//},
	}
	l, err := lc.Listen(ctx, "tcp", ":8080")
	if err != nil {
		e.Logger.Error("failed to create listener", "error", err)
		return
	}
	defer l.Close()

	sc := echo.StartConfig{
		Listener: l,
	}
	if err := sc.Start(ctx, e); err != nil {
		e.Logger.Error("failed to run server", "error", err)
	}
}

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (19364e2) to head (5571024).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2920   +/-   ##
=======================================
  Coverage   93.01%   93.01%           
=======================================
  Files          43       43           
  Lines        4496     4498    +2     
=======================================
+ Hits         4182     4184    +2     
  Misses        196      196           
  Partials      118      118           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aldas aldas merged commit 675712d into labstack:master Mar 19, 2026
10 checks passed
@aldas aldas deleted the start_config_listener branch March 19, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant