Krosxx / retrofit-rest-client

📡 A http client for Android Studio.
https://plugins.jetbrains.com/plugin/13075-retrofit-rest-client-2-0/
Apache License 2.0
52 stars 7 forks source link
android android-studio android-studio-plugin http-client idea-plugin kotlin rest-client retrofit retrofit2

Retrofit Rest Client

The best http client for Android Studio.

This plugin is based on idea-rest-client.

  • Support run retrofit api interface functions directly支持直接从 retrofit 接口函数执行
  • Supports GET, POST, PUT, DELETE, PATCH requests
  • Multiline request parameters
  • Rest file type support
  • Internally supported dynamic parameters(动态参数配置支持)
  • Response auto format (based on response Content-Type header)
  • Customized colors and fonts
  • Customized keyboard shortcuts
  • Comments
  • Support large body download(支持响应体下载)
  • Support un-text download and preview(支持非文本类型下载及打开预览)

使用方法:
1. 新建 xxx.rest 格式文件,按照 Preview 编辑即可
2. 直接在 Retrofit Api 函数左侧 Run 即可

How to use:
1. New a xxx.rest file,and edit like preview
2. Click the Run icon which left in Retrofit Api function

Preview

You can create rest file to edit.

Content structure

PreView

Run retrofit api method

Run retrofit api method

Demo

GET
{BASE_URL}/get
# query params
&id=1
&type=2

# headers
@Content-Type: application/json
@timestamp: {TS_SEC} # current time in seconds

Retrofit Guide

We can find execute icon on api method:

click the icon will create a rest file in {PROJECT_DIR}/.idea/rest-client/pkg/cls_fun.rest

GET
{BASE_URL}/abc
&q={q}

# Headers
@a: {a}

don't forget Set env params

Set env params

You can use {name} to reference env variable.

  1. To create json file {PROJECT_DIR}/.idea/rest-client/rest_env.json(Auto create)
{
  "test": {
    "BASE_URL": "http://localhost:8080",
    //common headers
    "headers": {
      "Content-Type": "application/json",
      "timestamp": "{TS}"
    },
    "user_id": "1",
    "a" : "a",
    "b" : "b"
  },
  "dev": {
    "BASE_URL": "http://xxx.xxxx.xxx"
  }
}
  1. Choose env to tun

Install

  1. Marketplace

IDEA or Android Studio Settings/Plugins/Marketplace search Retrofit Rest Client

  1. download [Retrofit Rest Client-2.3.0.zip](Retrofit Rest Client-2.3.0.zip) file.

Settings/Plugins/ Install Plugin from Disk.

Advanced

{TS}

GET
http://xx.xx.xx/api
@timestamp: {TS}   # current time in milliseconds
@timestamp_sec: {TS_SEC}   # current time in seconds
@timestamp_custom: {TS_yyyy-MM-dd#HH:mm:ss}   # current time custom format with SimpleDateFormat (use '#' instead of ' ')

Chunked file support

If your response is too large, the plugin will start download response-body to a file.

When download complete, you can open this file by following actions:

By the way, if you need your json formatter plugin of browser, please enable Allow access to file URLs

Thanks

This plugin is based on idea-rest-client.

TODO