Code Monkey home page Code Monkey logo

Comments (7)

nszaaa3 avatar nszaaa3 commented on May 25, 2024

前后端约定好封装格式,写一个接口文件可以全局用。

from easyhttp.

dary123 avatar dary123 commented on May 25, 2024

前后端约定好封装格式,写一个接口文件可以全局用。

但是不同的接口肯定要写多个文件的,比如登录注册这块,之前用retrofit的时候只需要创建一个LogReg_Interface就行了,里面包含多个接口,但是这个库一个接口就需要创建一个接口文件,每个接口传的参数不可能一样的,所以没法全局用一个文件呀

from easyhttp.

dary123 avatar dary123 commented on May 25, 2024

微信截图_20200628104329
像这样,这个文件只能用于一个接口,不是太浪费了吗

from easyhttp.

nszaaa3 avatar nszaaa3 commented on May 25, 2024

嘿嘿,我的意思是在前后端约定好封装的格式把数据封装在一个json里,不直接通过字段来请求,这样在调用接口的时候,只需要填parameter就可以。
image

from easyhttp.

getActivity avatar getActivity commented on May 25, 2024

把接口所有信息包装到一个类中,好处是维护起来方便,下次调用这个接口的时候不需要再去看后台文档,当后台接口有变动的时候,不需要一个个地方修改,只需要在这个类中修改就可以了

from easyhttp.

getActivity avatar getActivity commented on May 25, 2024

前期开发的优势并不大,后期维护才能展现魅力

from easyhttp.

nszaaa3 avatar nszaaa3 commented on May 25, 2024

我才理解你是不是想问怎么区分接口地址。。我的做法是服务端只暴露一个接口地址,移动端在接口文件里就只写这一个接口地址,那么服务端区分调用哪个接口的方法是根据移动端在header里边传的接口名或者新建一个字段用来传递调用哪个方法。

from easyhttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.