mirror of
https://github.com/lloeki/nanoserve.git
synced 2025-12-06 03:04:39 +01:00
Implement request host, path and content_type access
This commit is contained in:
parent
dd5001cb7c
commit
66a2a20663
1 changed files with 12 additions and 0 deletions
|
|
@ -98,6 +98,14 @@ module NanoServe
|
|||
@body = +''.encode('ASCII-8BIT')
|
||||
end
|
||||
|
||||
def host
|
||||
@headers['host']
|
||||
end
|
||||
|
||||
def path
|
||||
@uri.path
|
||||
end
|
||||
|
||||
def params
|
||||
Hash[*@uri.query.split('&').map { |kv| kv.split('=') }.flatten]
|
||||
end
|
||||
|
|
@ -132,6 +140,10 @@ module NanoServe
|
|||
@headers.key?('content-length')
|
||||
end
|
||||
|
||||
def content_type
|
||||
@headers['content-type']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
REQ_RE = %r{(?<method>[A-Z]+)\s+(?<path>\S+)\s+(?<version>HTTP/\d+.\d+)$}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue