server_other.go 467 B

123456789101112131415161718192021
  1. //go:build !windows
  2. // +build !windows
  3. package core
  4. import (
  5. "time"
  6. "github.com/fvbock/endless"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func initServer(address string, router *gin.Engine) server {
  10. s := endless.NewServer(address, router)
  11. s.ReadHeaderTimeout = 20 * time.Second
  12. // Keep streaming responses alive; individual handlers still honor request
  13. // cancellation when the browser closes the connection.
  14. s.WriteTimeout = 0
  15. s.MaxHeaderBytes = 1 << 20
  16. return s
  17. }