@@ -20,10 +20,10 @@ import (
2020var webpage []byte
2121
2222type task struct {
23- Method string `json:"method"`
24- URL string `json:"url"`
25- Extra any `json:"extra,omitempty"`
26- StreamResponse bool `json:"streamResponse"`
23+ Method string `json:"method"`
24+ URL string `json:"url"`
25+ Extra any `json:"extra,omitempty"`
26+ StreamResponse bool `json:"streamResponse"`
2727}
2828
2929var conns chan * websocket.Conn
@@ -51,9 +51,9 @@ func Reload() {
5151 if HasBrowserDialer () {
5252 for len (conns ) > 0 {
5353 select {
54- case c := <- conns :
55- c .Close ()
56- default :
54+ case c := <- conns :
55+ c .Close ()
56+ default :
5757 }
5858 }
5959 conns = nil
@@ -75,7 +75,7 @@ func Reload() {
7575 }
7676 }
7777 } else {
78- w .Header ().Set ("Access-Control-Allow-Origin" , "*" );
78+ w .Header ().Set ("Access-Control-Allow-Origin" , "*" )
7979 w .Write (webpage )
8080 }
8181 }),
@@ -94,15 +94,13 @@ type webSocketExtra struct {
9494
9595func DialWS (uri string , ed []byte ) (* websocket.Conn , error ) {
9696 task := task {
97- Method : "WS" ,
98- URL : uri ,
97+ Method : "WS" ,
98+ URL : uri ,
9999 StreamResponse : true ,
100100 }
101101
102- if ed != nil {
103- task .Extra = webSocketExtra {
104- Protocol : base64 .RawURLEncoding .EncodeToString (ed ),
105- }
102+ task .Extra = webSocketExtra {
103+ Protocol : base64 .RawURLEncoding .EncodeToString (ed ),
106104 }
107105
108106 return dialTask (task )
@@ -144,9 +142,9 @@ func httpExtraFromHeadersAndCookies(headers http.Header, cookies []*http.Cookie)
144142
145143func DialGet (uri string , headers http.Header , cookies []* http.Cookie ) (* websocket.Conn , error ) {
146144 task := task {
147- Method : "GET" ,
148- URL : uri ,
149- Extra : httpExtraFromHeadersAndCookies (headers , cookies ),
145+ Method : "GET" ,
146+ URL : uri ,
147+ Extra : httpExtraFromHeadersAndCookies (headers , cookies ),
150148 StreamResponse : true ,
151149 }
152150
@@ -159,9 +157,9 @@ func DialPacket(method string, uri string, headers http.Header, cookies []*http.
159157
160158func dialWithBody (method string , uri string , headers http.Header , cookies []* http.Cookie , payload []byte ) error {
161159 task := task {
162- Method : method ,
163- URL : uri ,
164- Extra : httpExtraFromHeadersAndCookies (headers , cookies ),
160+ Method : method ,
161+ URL : uri ,
162+ Extra : httpExtraFromHeadersAndCookies (headers , cookies ),
165163 StreamResponse : false ,
166164 }
167165
@@ -222,4 +220,3 @@ func CheckOK(conn *websocket.Conn) error {
222220func init () {
223221 Reload ()
224222}
225-
0 commit comments