LoginSignup
0
0

More than 3 years have passed since last update.

リクエストパラメータに情報を含めず ヘッダーに設定する方法

Posted at

結論:実装は以下

 @GetMapping(path = "/hoge", produces = "application/json")
    public Response getSproItems(@Validated Request request,
                                @RequestHeader  (value="User-Agent", required=false) String agent,
                                @RequestHeader("Cookie") String cookie)
        return service.getResponse(request,agent,cookie) 
    }

リクエストURL

https://hoge.jp/hoge?query=apple&results=30&in_stock=true
クエリ:apple
件数:30
在庫有無:有

ARCで送るとこんな感じ。
719dd75ea2d1ef06a2e0304ce21115c5.png

するとリクエストパラメータ(query=apple&results=30&in_stock=true)は
格納用のクラスに格納され、
リクエストヘッダーの情報は、string型として別で保管されます。

情報をリクエストURLに
含めたくないときは便利かもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0