mirror of
				https://github.com/eolinker/apinto
				synced 2025-10-31 20:12:56 +08:00 
			
		
		
		
	Feature/plugin
This commit is contained in:
		
							
								
								
									
										75
									
								
								node/http-context/uri.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								node/http-context/uri.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| package http_context | ||||
|  | ||||
| import ( | ||||
| 	http_service "github.com/eolinker/eosc/http-service" | ||||
| 	"github.com/valyala/fasthttp" | ||||
| ) | ||||
|  | ||||
| var _ http_service.IURIWriter = (*URIRequest)(nil) | ||||
|  | ||||
| type URIRequest struct { | ||||
| 	uri *fasthttp.URI | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) Path() string { | ||||
| 	return string(ur.uri.Path()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) SetScheme(scheme string) { | ||||
| 	ur.uri.SetScheme(scheme) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) Host() string { | ||||
| 	return string(ur.uri.Host()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) SetQuery(key, value string) { | ||||
|  | ||||
| 	ur.uri.QueryArgs().Set(key, value) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) AddQuery(key, value string) { | ||||
| 	ur.uri.QueryArgs().Add(key, value) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) DelQuery(key string) { | ||||
| 	ur.uri.QueryArgs().Del(key) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) SetRawQuery(raw string) { | ||||
| 	ur.uri.SetQueryString(raw) | ||||
| } | ||||
|  | ||||
| func NewURIRequest(uri *fasthttp.URI) *URIRequest { | ||||
| 	return &URIRequest{uri: uri} | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) RequestURI() string { | ||||
| 	return string(ur.uri.RequestURI()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) Scheme() string { | ||||
| 	return string(ur.uri.Scheme()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) RawURL() string { | ||||
| 	return string(ur.uri.FullURI()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) GetQuery(key string) string { | ||||
|  | ||||
| 	return string(ur.uri.QueryArgs().Peek(key)) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) RawQuery() string { | ||||
| 	return string(ur.uri.QueryString()) | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) SetPath(s string) { | ||||
| 	ur.uri.SetPath(s) | ||||
|  | ||||
| } | ||||
|  | ||||
| func (ur *URIRequest) SetHost(host string) { | ||||
| 	ur.uri.SetHost(host) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 黄孟柱
					黄孟柱