github.com/moqsien/xraycore@v1.8.5/transport/internet/websocket/config.go (about)

     1  package websocket
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/moqsien/xraycore/common"
     7  	"github.com/moqsien/xraycore/transport/internet"
     8  )
     9  
    10  const protocolName = "websocket"
    11  
    12  func (c *Config) GetNormalizedPath() string {
    13  	path := c.Path
    14  	if path == "" {
    15  		return "/"
    16  	}
    17  	if path[0] != '/' {
    18  		return "/" + path
    19  	}
    20  	return path
    21  }
    22  
    23  func (c *Config) GetRequestHeader() http.Header {
    24  	header := http.Header{}
    25  	for _, h := range c.Header {
    26  		header.Add(h.Key, h.Value)
    27  	}
    28  	return header
    29  }
    30  
    31  func init() {
    32  	common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
    33  		return new(Config)
    34  	}))
    35  }