From 23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 12 Aug 2023 09:40:39 -0600 Subject: move common types to an internal package This helps avoid import cycles. --- request.go | 48 ++---------------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) (limited to 'request.go') diff --git a/request.go b/request.go index dce8acb..c934b30 100644 --- a/request.go +++ b/request.go @@ -1,49 +1,5 @@ package sliderule -import ( - "crypto/tls" - "net" - "net/url" -) +import "tildegit.org/tjp/sliderule/internal/types" -// Request represents a request over any small web protocol. -// -// Because protocols have so many differences, this type represents a -// greatest common denominator of request/response-oriented protocols. -type Request struct { - // URL is the specific URL being fetched by the request. - *url.URL - - // Server is the server which received the request. - // - // This is only populated in servers. - // It is unused on the client end. - Server Server - - // Meta is a place for opaque data. - // - // Look for helper methods in protocol packages to use it appropriately - // for the protocol. - Meta any - - // RemoteAddr is the address of the other side of the connection. - // - // This will be the server address for clients, or the connecting - // client's address in servers. - // - // Be aware though that proxies (and reverse proxies) can confuse this. - RemoteAddr net.Addr - - // TLSState contains information about the TLS encryption over the connection. - // - // This includes peer certificates and version information. - TLSState *tls.ConnectionState -} - -// UnescapedQuery performs %XX unescaping on the URL query segment. -// -// Like URL.Query(), it silently drops malformed %-encoded sequences. -func (req Request) UnescapedQuery() string { - unescaped, _ := url.QueryUnescape(req.RawQuery) - return unescaped -} +type Request = types.Request -- cgit v1.2.3