added upgrade.Request and Response getters for websocket routing (URI + protocol)
This commit is contained in:
parent
d16a0830d0
commit
741a243f87
|
@ -37,3 +37,9 @@ func (r *T) Parse(b []byte) error {
|
|||
return nil
|
||||
|
||||
}
|
||||
|
||||
|
||||
// GetURI returns the actual URI
|
||||
func (r T) GetURI() string {
|
||||
return r.uri
|
||||
}
|
|
@ -58,19 +58,6 @@ func Parse(r io.Reader) (request *T, err error) {
|
|||
|
||||
|
||||
|
||||
// String returns a textual representation of the upgrade request
|
||||
func (r T) String() string{
|
||||
|
||||
l1 := fmt.Sprintf("Upgrade Request\n - host: %s\n - port: %d\n - origin: %s\n", r.host, r.port, r.origin)
|
||||
l2 := fmt.Sprintf(" - origin policy: %t\n - connection header: %t\n - upgrade header: %t\n - valid ws version: %t\n", r.validPolicy, r.hasConnection, r.hasUpgrade, r.hasVersion)
|
||||
l3 := fmt.Sprintf(" - key: %s\n - protocols: %s\n", r.key, r.protocols)
|
||||
l4 := fmt.Sprintf(" - current status: %d %s\n", r.code, r.code.Message())
|
||||
|
||||
|
||||
return fmt.Sprintf("%s%s%s%s", l1, l2, l3, l4)
|
||||
}
|
||||
|
||||
|
||||
// StatusCode returns the status current
|
||||
func (r T) StatusCode() response.StatusCode {
|
||||
return r.code
|
||||
|
@ -96,3 +83,10 @@ func (r *T) BuildResponse() *response.T{
|
|||
|
||||
return inst
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GetURI returns the actual URI
|
||||
func (r T) GetURI() string{
|
||||
return r.request.GetURI()
|
||||
}
|
||||
|
|
|
@ -59,3 +59,8 @@ func (r T) Send(w io.Writer) (int, error) {
|
|||
return written, err
|
||||
|
||||
}
|
||||
|
||||
// GetProtocol returns the choosen protocol if set, else nil
|
||||
func (r T) GetProtocol() []byte {
|
||||
return r.protocol
|
||||
}
|
Loading…
Reference in New Issue