1- ![ main] ( https://github.com/devyhan/apirouter /actions/workflows/ci.yml/badge.svg?branch=main )
2- [ ![ codecov] ( https://codecov.io/gh/devyhan/APIRouter /branch/main/graph/badge.svg?token=ZQNDOX2VDF )] ( https://codecov.io/gh/devyhan/APIRouter )
1+ ![ main] ( https://github.com/devyhan/urlrouter /actions/workflows/ci.yml/badge.svg?branch=main )
2+ [ ![ codecov] ( https://codecov.io/gh/devyhan/URLRouter /branch/main/graph/badge.svg?token=ZQNDOX2VDF )] ( https://codecov.io/gh/devyhan/APIRouter )
33[ ![ ] ( https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdevyhan%2FAPIRouter%2Fbadge%3Ftype%3Dswift-versions )] ( https://swiftpackageindex.com/devyhan/APIRouter )
44[ ![ ] ( https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdevyhan%2FAPIRouter%2Fbadge%3Ftype%3Dplatforms )] ( https://swiftpackageindex.com/devyhan/APIRouter )
55
66<p align =" center " >
77 <img src =" https://user-images.githubusercontent.com/45344633/208562346-19b44df3-c581-4f32-af8e-d85dbc99ec18.png " />
88</p >
99
10- ## What's APIRouter 📟
11- *** APIRouter *** is provides an easy way to manage multiple RESTful API endpoints in Swift.
10+ ## What's URLRouter 📟
11+ *** URLRouter *** is provides an easy way to manage multiple URL endpoints in Swift.
1212It provides a simple interface for managing multiple endpoints and allows developers to interact with them in a single, unified manner.
1313It also provides a way for developers to create custom endpoints DSL(Domain-Specific Languages) and to manage their own settings for each endpoint.
1414Additionally, it provides a way to track the status of each endpoint and to easily detect any changes or updates that have been made.
1515
1616Similar to Swift Evolution's [ Regex builder DSL] ( https://github.com/apple/swift-evolution/blob/main/proposals/0351-regex-builder.md ) , URL string literal and a more powerful pattern result builder to help make Swift URL string processing fast and easy and without mistakes. Ultimately, with *** APIRouter*** , changes are easy to detect and useful for maintenance.
1717
18- 🤔 * Ask questions you’re wondering about [ here] ( https://github.com/devyhan/APIRouter /discussions/new?category=q-a ) .* <br />
18+ 🤔 * Ask questions you’re wondering about [ here] ( https://github.com/devyhan/URLRouter /discussions/new?category=q-a ) .* <br />
1919💡 * Share ideas [ here] ( https://github.com/devyhan/APIRouter/discussions/new ) .*
2020
2121## Installation 📦
@@ -27,18 +27,18 @@ Similar to Swift Evolution's [Regex builder DSL](https://github.com/apple/swift-
2727 let package = Package (
2828 name : " SomeApp" ,
2929 dependencies : [
30- .Package (url : " https://github.com/devyhan/APIRouter " , majorVersion : " <LATEST_RELEASES_VERSION>" ),
30+ .Package (url : " https://github.com/devyhan/URLRouter " , majorVersion : " <LATEST_RELEASES_VERSION>" ),
3131 ]
3232 )
3333 ```
3434
35- ## Configure APIRouter 📝
36- ### Implement APIs Namespace
37- - To implement APIs namespace we create a new type that will house the domain and behavior of the APIs by conforming to `RouterProtocol`.
35+ ## Configure URLRouter 📝
36+ ### Implement URLs Namespace
37+ - To implement URLs namespace we create a new type that will house the domain and behavior of the URLs by conforming to `RouterProtocol`.
3838```swift
39- import APIRouter
39+ import URLRouter
4040
41- public enum APIs : RouterProtocol {
41+ public enum URLs : RouterProtocol {
4242 ...
4343}
4444```
@@ -231,18 +231,19 @@ Request {
231231}
232232```
233233---
234- ### How to configure and use *** APIRouter *** in a real project?
235- - Just create APIRouter .swift in your project! Happy hacking! 😁
234+ ### How to configure and use *** URLRouter *** in a real world project?
235+ - Just create URLRouter .swift in your project! Happy hacking! 😁
236236``` swift
237- import APIRouter
237+ import URLRouter
238238
239- enum APIs : RouterProtocol {
239+ enum URLs : RouterProtocol {
240240 // DOC: https://docs.github.com/ko/rest/repos/repos?apiVersion=2022-11-28#list-organization-repositories
241241 case listOrganizationRepositories (organizationName : String )
242242 // DOC: https://docs.github.com/ko/rest/repos/repos?apiVersion=2022-11-28#create-an-organization-repository
243243 case createAnOrganizationRepository (organizationName : String , repositoryInfo : RepositoryInfo)
244244 // DOC: https://docs.github.com/ko/rest/search?apiVersion=2022-11-28#search-repositories
245245 case searchRepositories (query : String )
246+ case deeplink (path : String = "home")
246247
247248 struct RepositoryInfo {
248249 let name: String
@@ -304,25 +305,53 @@ enum APIs: RouterProtocol {
304305 Query (" q" , value : query)
305306 }
306307 }
308+ case let .deeplink (path):
309+ URL {
310+ Scheme.custom (" example-deeplink" )
311+ Host (" detail" )
312+ Path (path)
313+ Query {
314+ Field (" postId" , forKey : " 1" )
315+ Field (" createdAt" , forKey : " 2021-04-27T04:39:54.261Z" )
316+ }
317+ }
307318 }
308319 }
309320 }
310321}
311322
312323// http://api.github.com/orgs/organization/repos
313- let listOrganizationRepositoriesUrl = APIs .listOrganizationRepositories (organizationName : " organization" ).router ? .urlRequest ? .url
324+ let listOrganizationRepositoriesUrl = URLs .listOrganizationRepositories (organizationName : " organization" ).router ? .urlRequest ? .url
314325
315- // http://api.github.com/search/repositories?q=apirouter
316- let searchRepositoriesUrl = APIs .searchRepositories (query : " apirouter " ).router ? .urlRequest ? .url
326+ // http://api.github.com/search/repositories?q=urlrouter
327+ let searchRepositoriesUrl = URLs .searchRepositories (query : " urlrouter " ).router ? .urlRequest ? .url
317328
318- let repositoryInfo: APIs.RepositoryInfo = .init (name : " Hello-World" , description : " This is your first repository" , homePage : " https://github.com" , private : false , hasIssues : true , hasProjects : true , hasWiki : false )
319- let request = APIs.createAnOrganizationRepository (organizationName : " SomeOrganization" , repositoryInfo : repositoryInfo).router ? .urlRequest
329+ // example-deeplink://detail/comments?1=postId&2021-04-27T04:39:54.261Z=createdA
330+ let deeplink = URLs.deeplink (path : " detail" ).router .url
331+ ```
332+ - Using *** URLRouter*** to provide ` URLRequest ` .
333+ ``` swift
334+ let repositoryInfo: URLs.RepositoryInfo = .init (name : " Hello-World" , description : " This is your first repository" , homePage : " https://github.com" , private : false , hasIssues : true , hasProjects : true , hasWiki : false )
335+ let request = URLs.createAnOrganizationRepository (organizationName : " SomeOrganization" , repositoryInfo : repositoryInfo).router ? .urlRequest
320336
321337URLSession.shared .dataTask (with : request) { data, response, error in
322338...
323339```
340+ - Using *** URLRouter*** to provide deeplink `URL` and check to match this `URL`.
341+ ```swift
342+ class AppDelegate : UIResponder , UIApplicationDelegate {
343+ ...
344+ func application (_ app : UIApplication, open url : URL, options : [UIApplication.OpenURLOptionsKey: Any ]) -> Bool {
345+ let detailDeeplink = URLs.deeplink (path : " detail" ).router .url
346+ if detailDeeplink == url {
347+ ...
348+ }
349+ ...
350+ ```
324351## License
325352
326- *** APIRouter *** is under MIT license. See the [LICENSE](LICENSE) file for more info.
353+ *** URLRouter *** is under MIT license. See the [LICENSE](LICENSE) file for more info.
327354
355+ ---
356+ ! [GitHub release (latest SemVer)](https :// img.shields.io/github/v/release/devyhan/urlrouter?style=social)
328357[! [Twitter Follow @devyhan93 ](https :// img.shields.io/twitter/follow/devyhan93?style=social)](https://twitter.com/devyhan93)
0 commit comments