File tree Expand file tree Collapse file tree
Tool/Sources/BingSearchService Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,15 +48,20 @@ public struct BingSearchService {
4848 self . searchURL = searchURL
4949 }
5050
51- public func search( query: String , numberOfResult: Int ) async throws -> BingSearchResult {
51+ public func search(
52+ query: String ,
53+ numberOfResult: Int ,
54+ freshness: String ? = nil
55+ ) async throws -> BingSearchResult {
5256 guard let url = URL ( string: searchURL)
5357 else { throw BingSearchError . searchURLFormatIncorrect ( searchURL) }
5458
5559 var components = URLComponents ( url: url, resolvingAgainstBaseURL: true )
5660 components? . queryItems = [
5761 . init( name: " q " , value: query) ,
5862 . init( name: " count " , value: String ( numberOfResult) ) ,
59- ]
63+ freshness. map { . init( name: " freshness " , value: $0) } ,
64+ ] . compactMap { $0 }
6065 var request = URLRequest ( url: components? . url ?? url)
6166 request. httpMethod = " GET "
6267 request. addValue ( subscriptionKey, forHTTPHeaderField: " Ocp-Apim-Subscription-Key " )
You can’t perform that action at this time.
0 commit comments