26 lines
375 B
Go
26 lines
375 B
Go
package upgrader
|
|
|
|
import (
|
|
"fmt"
|
|
"git.xdrm.io/gws/internal/http/upgrade/request"
|
|
"net"
|
|
)
|
|
|
|
|
|
func Upgrade(s net.Conn) error {
|
|
|
|
/* (1) Parse request */
|
|
req, _ := request.Parse(s)
|
|
|
|
/* (2) Build response */
|
|
res := req.BuildResponse()
|
|
|
|
/* (3) Write into socket */
|
|
_, err := res.Send(s)
|
|
if err != nil {
|
|
return fmt.Errorf("Socket write error: %s", err)
|
|
}
|
|
|
|
return nil
|
|
|
|
} |