mirror of
https://github.com/soypat/lneto.git
synced 2026-08-18 21:54:01 +00:00
add a pattern argument to Mux
This commit is contained in:
@@ -38,6 +38,8 @@ type Exchange struct {
|
||||
hijacked bool
|
||||
rw conn
|
||||
|
||||
matchedPattern string
|
||||
|
||||
respRemains int
|
||||
respErr error // Sticky: response is unrecoverable once a write fails.
|
||||
headerWritten bool
|
||||
@@ -97,6 +99,7 @@ func (exch *Exchange) Acquire(conn conn) bool {
|
||||
if !exch.used.CompareAndSwap(false, true) {
|
||||
return false
|
||||
}
|
||||
exch.matchedPattern = ""
|
||||
exch.gen.Add(1)
|
||||
exch.readErr = nil
|
||||
exch.respErr = nil
|
||||
@@ -366,6 +369,11 @@ func (exch *Exchange) remainingSurplusBody() ([]byte, error) {
|
||||
return toRead, nil
|
||||
}
|
||||
|
||||
// MuxPattern returns the pattern [Mux] matched to the request.
|
||||
func (exch *Exchange) MuxPattern() string {
|
||||
return exch.matchedPattern
|
||||
}
|
||||
|
||||
// RequestHeaderRaw returns the parsed request header for access beyond the
|
||||
// Request* methods, such as [httpraw.Header.ForEach]. Valid until the exchange
|
||||
// is released, and writing to it corrupts the response.
|
||||
|
||||
Reference in New Issue
Block a user