github.com/searKing/golang/go@v1.2.117/net/mux/matcher_http.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mux
     6  
     7  import (
     8  	"io"
     9  
    10  	"github.com/searKing/golang/go/net/mux/internal/http"
    11  )
    12  
    13  // PRI * HTTP/2.0\r\n\r\n
    14  // HTTP parses the first line or upto 4096 bytes of the request to see if
    15  // the connection contains an HTTP request.
    16  func HTTP() MatcherFunc {
    17  	return func(_ io.Writer, r io.Reader) bool {
    18  		req := http.ReadRequestLine(r)
    19  		if req == nil {
    20  			return false
    21  		}
    22  		return true
    23  	}
    24  }