-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tech debt: refactor the URL router, potentially resolve #236, log all…
… HTTP headers instead of just a subset
- Loading branch information
1 parent
ef5f94c
commit 7b15b7b
Showing
36 changed files
with
1,471 additions
and
1,423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import BSON | ||
import UnidocAPI | ||
|
||
extension Unidoc | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import HTTP | ||
import NIOHTTP1 | ||
import NIOHPACK | ||
|
||
extension HTTP | ||
{ | ||
@frozen @usableFromInline | ||
enum Headers:Equatable, Sendable | ||
{ | ||
case http1_1(HTTPHeaders) | ||
case http2(HPACKHeaders) | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
Sources/UnidocServer/Administration/ServerTour.Request.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import HTML | ||
import HTTP | ||
import HTTPServer | ||
import IP | ||
import NIOHPACK | ||
import URI | ||
|
||
extension ServerTour | ||
{ | ||
@frozen @usableFromInline | ||
struct Request:Equatable, Sendable | ||
{ | ||
var version:HTTP | ||
var headers:HTTP.Headers | ||
var origin:IP.Origin | ||
var uri:URI | ||
|
||
init( | ||
version:HTTP, | ||
headers:HTTP.Headers, | ||
origin:IP.Origin, | ||
uri:URI) | ||
{ | ||
self.version = version | ||
self.headers = headers | ||
self.origin = origin | ||
self.uri = uri | ||
} | ||
} | ||
} | ||
extension ServerTour.Request:HTML.OutputStreamable | ||
{ | ||
@usableFromInline static | ||
func += (dl:inout HTML.ContentEncoder, self:Self) | ||
{ | ||
let uri:String = "\(self.uri)" | ||
|
||
dl[.dt] = "Path" | ||
dl[.dd] { $0[.a] { $0.href = "\(uri)" } = "\(uri)" } | ||
|
||
dl[.dt] = "IP address" | ||
dl[.dd] = "\(self.origin.address)" | ||
|
||
switch self.headers | ||
{ | ||
case .http1_1(let headers): | ||
for (name, value):(String, String) in headers | ||
{ | ||
dl[.dt] = name | ||
dl[.dd] = value | ||
} | ||
|
||
case .http2(let headers): | ||
for (name, value, _):(String, String, HPACKIndexing) in headers | ||
{ | ||
if case ":"? = name.first | ||
{ | ||
continue | ||
} | ||
|
||
dl[.dt] = name | ||
dl[.dd] = value | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.