久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='NWTKO'></tfoot>

      <legend id='NWTKO'><style id='NWTKO'><dir id='NWTKO'><q id='NWTKO'></q></dir></style></legend>
      • <bdo id='NWTKO'></bdo><ul id='NWTKO'></ul>

      <small id='NWTKO'></small><noframes id='NWTKO'>

      <i id='NWTKO'><tr id='NWTKO'><dt id='NWTKO'><q id='NWTKO'><span id='NWTKO'><b id='NWTKO'><form id='NWTKO'><ins id='NWTKO'></ins><ul id='NWTKO'></ul><sub id='NWTKO'></sub></form><legend id='NWTKO'></legend><bdo id='NWTKO'><pre id='NWTKO'><center id='NWTKO'></center></pre></bdo></b><th id='NWTKO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NWTKO'><tfoot id='NWTKO'></tfoot><dl id='NWTKO'><fieldset id='NWTKO'></fieldset></dl></div>

      如何最好地設計具有多個過濾器的 REST API?

      How best to design a REST API with multiple filters?(如何最好地設計具有多個過濾器的 REST API?)

        <bdo id='ejdqx'></bdo><ul id='ejdqx'></ul>
          <tbody id='ejdqx'></tbody>

            <legend id='ejdqx'><style id='ejdqx'><dir id='ejdqx'><q id='ejdqx'></q></dir></style></legend>
            <i id='ejdqx'><tr id='ejdqx'><dt id='ejdqx'><q id='ejdqx'><span id='ejdqx'><b id='ejdqx'><form id='ejdqx'><ins id='ejdqx'></ins><ul id='ejdqx'></ul><sub id='ejdqx'></sub></form><legend id='ejdqx'></legend><bdo id='ejdqx'><pre id='ejdqx'><center id='ejdqx'></center></pre></bdo></b><th id='ejdqx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ejdqx'><tfoot id='ejdqx'></tfoot><dl id='ejdqx'><fieldset id='ejdqx'></fieldset></dl></div>
              <tfoot id='ejdqx'></tfoot>

              <small id='ejdqx'></small><noframes id='ejdqx'>

                本文介紹了如何最好地設計具有多個過濾器的 REST API?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                作為一個個人編程項目,我正在努力抓取我大學的課程目錄并將數據作為 REST API 提供.我已成功抓取所有數據并將其存儲在數據庫中,現在正在開發 API.

                As a personal programming project, I am working on scraping my University's course catalog and providing the data as a REST API. I have successfully scraped all the data and stored it in a database, and am now working on the API.

                可以根據許多標準過濾課程:講師、大學、學分、時間、天數等.

                The courses can be filtered on the basis of many criteria: instructor, college, credits, time, day etc.

                在這種情況下提供 API 的最佳方式是什么?

                What is the best way to provide an API in this situation?

                選項 1

                提供多個 URL,例如

                Provide numerous URLs such as

                example.com/api/byinstructor/<instructorcode>
                example.come/api/bycollege/<collegecode>
                example.com/api/bycollegeandinstructor/<collegecode>/<instructorcode>
                ...and so on
                

                我需要所有排列的 URL.這對于我和 API 消費者來說似乎非常麻煩,而且非常不干.

                I would need to have a URL for all permutations. This seems very cumbersome, both for me and the API consumers, and very un-DRY.

                選項 2

                僅提供主要選項的 API,例如:

                Only provide APIs for the major options like:

                example.com/api/byinstructor/<instructorcode>
                example.come/api/bycollege/<collegecode>
                

                如果消費者想要bycollegeandinstructor,他會在自己的一端進行過濾.

                And if the consumer wants bycollegeandinstructor, he does the filtering on his end.

                選項 3

                用戶向我傳遞一個 JSON 字符串,我用它來獲取過濾條件

                The user passes a JSON string to me, and I use that to get the filtering criteria

                example.com/api/getcourses/<jsonstring>
                
                jsonstring = 
                { 
                  instructor:<instructorcode>,
                  college:<collegecode>,
                  ...and so on
                }
                

                我想除了 Json 字符串,我還可以需要一個 POST 數組,但這對消費者來說似乎不直觀,因為他正在 GET 數據.

                I suppose instead of the Json string, I could also require a POST array, but that seems un-inituitive for the consumer since he is GETing data.

                或者還有其他我不知道的方法嗎?如果第三個選項是最佳選項,您能否提供一個簡短的摘要,以便根據可能具有可變數量值的 JSOn 字符串準備 SQL 查詢?

                Or is there another way of doing this I am not aware of? If it is the third option that is the best option, could you provide a short summary best to prepare a SQL query on the basis of a JSOn string that may have variable number of values?

                推薦答案

                為了擴展 J.F. 的答案,聽起來您有一個資源,即課程集,位于 URI:

                To expand on the answer from J.F., it sounds like you have one resource, the set of courses, which would be at the URI:

                /courses
                

                過濾該資源通常是使用查詢參數來過濾單個資源來完成的,例如:

                Filtering that resource is usually accomplished using query parameters to filter that single resource, e.g:

                /courses?college=123&instructor=321
                

                通過這樣做,您可以避免所有可能的排列造成資源激增的問題.

                By doing this, you avoid the issue with all possible permutations creating a proliferation of resources.

                從根本上說:只有一種資源,可以根據需要對其進行過濾.

                Fundamentally: There's one resource, which can be filtered as necessary.

                這篇關于如何最好地設計具有多個過濾器的 REST API?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                  <i id='k5n4P'><tr id='k5n4P'><dt id='k5n4P'><q id='k5n4P'><span id='k5n4P'><b id='k5n4P'><form id='k5n4P'><ins id='k5n4P'></ins><ul id='k5n4P'></ul><sub id='k5n4P'></sub></form><legend id='k5n4P'></legend><bdo id='k5n4P'><pre id='k5n4P'><center id='k5n4P'></center></pre></bdo></b><th id='k5n4P'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='k5n4P'><tfoot id='k5n4P'></tfoot><dl id='k5n4P'><fieldset id='k5n4P'></fieldset></dl></div>

                    <legend id='k5n4P'><style id='k5n4P'><dir id='k5n4P'><q id='k5n4P'></q></dir></style></legend>
                      <bdo id='k5n4P'></bdo><ul id='k5n4P'></ul>
                    • <tfoot id='k5n4P'></tfoot>

                          <tbody id='k5n4P'></tbody>
                        • <small id='k5n4P'></small><noframes id='k5n4P'>

                        • 主站蜘蛛池模板: 中文字幕一区二区三区四区 | 国产精品久久久 | 一区二区中文 | 日韩精品一区二区三区 | 国产精品成人一区二区三区夜夜夜 | 日韩另类 | 91国在线观看 | 国产成人一区二区 | 欧美a√ | 妖精视频一区二区三区 | 亚洲国产精品一区二区三区 | 国产精品久久久久久久免费观看 | 狠狠爱视频 | 美女视频一区 | 亚洲第一av | 国产精品99久久久久久宅男 | 国产精品成人在线播放 | 成人av一区二区在线观看 | 免费a国产 | 一级毛片免费视频观看 | 中文字幕a√ | 亚洲激情综合网 | 精品中文字幕一区二区三区 | 欧美日韩精品免费 | 久久久精品国产 | 日韩一区在线播放 | 中文字幕日韩一区 | 久久性色 | 国产精品毛片av | www.久久精品视频 | 国产日韩一区二区三区 | 91精品国产综合久久婷婷香蕉 | 久久久精品影院 | 亚洲一区二区三区四区五区午夜 | 免费人成在线观看网站 | 韩日精品一区 | 成人综合久久 | 久久国产精99精产国高潮 | 免费国产视频 | a爱视频 | 亚洲一区二区三区四区五区午夜 |