package upgrader import ( "git.xdrm.io/gws/internal/http/upgrade/response" "fmt" "git.xdrm.io/gws/internal/http/upgrade/request" "net" ) type T struct { Request *request.T Response *response.T } func Upgrade(s net.Conn) (*T, error) { /* (1) Create upgrder */ inst := new(T) /* (2) Parse request */ inst.Request, _ = request.Parse(s) /* (3) Build response */ inst.Response = inst.Request.BuildResponse() /* (4) Write into socket */ _, err := inst.Response.Send(s) if err != nil { return inst, fmt.Errorf("Socket write error: %s", err) } return inst, nil }