Rename and split Application.swift
#443
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景
古来、
Application.swift
にはextension Application
が書かれていました。これは
Vapor.Application
の事でした。以下のパッチにより、vapor の利用は廃止され、
このファイルには
Server.HTTPHandler
などが書かれるようになりました。2e62088#diff-f90940556aae24c2f20d9e1096fa58c020fda927ef748b3271a50e02e0ad1379
課題
ファイル名と中身が大きく異なっているため、
コードを読む時の見通しが悪いと感じました。
変更
Application.swift
を以下の3つのファイルに分割します。ServerHTTPHandler.swift
元ソースの
Server.HTTPHandler
のコードを移します。ServerWebSocketHandler.swift
元ソースの
Server.WebSocketHandler
のコードを移します。ContentTypes.swift
元ソースの
func contentType(of:)
のコードを移します。