CN107301137A - RSET interface realizing methods and device and electronic equipment and computer-readable recording medium - Google Patents
RSET interface realizing methods and device and electronic equipment and computer-readable recording medium Download PDFInfo
- Publication number
- CN107301137A CN107301137A CN201710536277.XA CN201710536277A CN107301137A CN 107301137 A CN107301137 A CN 107301137A CN 201710536277 A CN201710536277 A CN 201710536277A CN 107301137 A CN107301137 A CN 107301137A
- Authority
- CN
- China
- Prior art keywords
- interface
- rest
- controller
- interfaces
- backstage
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
Abstract
The embodiments of the invention provide a kind of RSET interface realizing methods and device and electronic equipment and computer-readable recording medium.Wherein, REST interfaces are used to connect front end and backstage;The RSET interface realizing methods can include:Obtain front end demand data;Based on front end demand data, interface interchange parameter and interface return value are determined;Based on interface interchange parameter and interface return value, the interactive operation between front end and backstage is determined according to REST specifications, so as to realize REST interfaces.The embodiment of the present invention due to realizing interface using REST specifications, so, the template that REST specifications can be annotated as interface function, so as to according to interface annotation generation interface document.The interface document is all known for front end and backstage, it is easy to understood.Therefore, the embodiment of the present invention solves the technical problem for how being easy to front end to be linked up with backstage;Moreover, it is also possible to real-time online preview interface document.
Description
Technical field
The present invention relates to Internet technical field, more particularly to a kind of RSET interface realizing methods and device and electronics are set
Standby and computer-readable recording medium.
Background technology
In mobile Internet application system development, interacting for front end and backstage all relies on interface to realize.
The instrument of existing development interface such as Swagger frameworks, I/O Docs interactive documents system, Docco document works
Tool etc..
Although above-mentioned interface facility can realize purpose, the comfort level difference used is very big.For example, current
When developer's docking port at end and backstage is unfamiliar with, communication disorders can be caused between front end and backstage, before thus causing
The exploitation at end and backstage wastes many times.
The content of the invention
The purpose of the embodiment of the present invention is to provide a kind of RSET interface realizing methods, to solve how to be easy to front end with after
The technical problem that platform is linked up.In addition, also providing a kind of RSET interfaces realizes device and electronic equipment and computer-readable storage medium
Matter.
To achieve these goals, according to an aspect of the invention, there is provided following technical scheme:
A kind of resource form of expression state shifts RSET interface realizing methods, wherein, the REST interfaces are used for before connecting
End and backstage;This method includes:
Obtain front end demand data;
Based on the front end demand data, interface interchange parameter and interface return value are determined;
Based on the interface interchange parameter and the interface return value, determined according to REST specifications the front end with it is described
Interactive operation between backstage, so as to realize the REST interfaces.
Further, it is described to be based on the interface interchange parameter and the interface return value, determined according to REST specifications
Interactive operation between the front end and the backstage, so as to realize the REST interfaces, is specifically included:
Based on the interface interchange parameter and the interface return value, HyperText Preprocessor THINKPHP frameworks and its life
Name space mode, and according to REST specifications, build the REST for realizing the interactive operation between the front end and the backstage
Interface.
Further, the THINKPHP frameworks include REST controllers;It is described to be based on the interface interchange parameter and institute
Interface return value, HyperText Preprocessor THINKPHP frameworks and its NameSpace mode are stated, and is built according to REST specifications
The REST interfaces, are specifically included:
Based on the interface interchange parameter and the interface return value and the THINKPHP frameworks, build interface and access
Controller;
The interface access controller is inherited into the REST controllers, the first controller is obtained;
In first controller, REST property parameters and REST routes are defined according to the REST specifications, are obtained
Second controller;Wherein, the REST property parameters and the REST route the operation for realizing the REST interfaces;
API functional units are encapsulated in NameSpace;Wherein, the API functional units and the front end demand data
It is corresponding;
The NameSpace for being packaged with the API functional units is configured in the second controller, the 3rd control is obtained
Device, and the THINKPHP frameworks that will carry the 3rd controller, are defined as the RSET interfaces.
To achieve these goals, according to another aspect of the present invention, following technical scheme is additionally provided:
A kind of resource form of expression state transfer RSET interfaces realize device, wherein, the REST interfaces are used for before connecting
End and backstage;Described device includes:
Acquisition module, for obtaining front end demand data;
First determining module, for based on the front end demand data, determining interface interchange parameter and interface return value;
Second determining module, for based on the interface interchange parameter and the interface return value, coming according to REST specifications
The interactive operation between the front end and the backstage is determined, so as to realize the REST interfaces.
Further, second determining module specifically for:
Based on the interface interchange parameter and the interface return value, HyperText Preprocessor THINKPHP frameworks and its life
Name space mode, and according to REST specifications, build the REST for realizing the interactive operation between the front end and the backstage
Interface.
Further, the THINKPHP frameworks include REST controllers;Second determining module is specifically included:
Construction unit, for based on the interface interchange parameter and the interface return value and the THINKPHP frames
Frame, builds interface access controller;
Unit is inherited, for the interface access controller to be inherited into the REST controllers, the first controller is obtained;
Definition unit, in first controller, defined according to the REST specifications REST property parameters and
REST is route, and obtains second controller;Wherein, the REST property parameters and the REST are route for realizing that the REST connects
The operation of mouth;
Encapsulation unit, for API functional units to be encapsulated in NameSpace;Wherein, the API functional units with it is described
Front end demand data is corresponding;
Dispensing unit, for the NameSpace for being packaged with the API functional units to be configured in the second controller,
The 3rd controller, and the THINKPHP frameworks that the 3rd controller will be carried are obtained, is defined as the RSET interfaces.
To achieve these goals, according to a further aspect of the invention, following technical scheme is additionally provided:
A kind of electronic equipment, it includes processor, communication interface, memory and communication bus, wherein, the processor,
The communication interface and the memory complete mutual communication by the communication bus;
The memory, for depositing computer program;
The processor, for performing during the program deposited on memory, realizes the method described in above-mentioned technical proposal
Step.
To achieve these goals, according to a further aspect of the invention, following technical scheme is additionally provided:
A kind of computer-readable recording medium, the computer-readable recording medium internal memory contains computer program, described
The method and step described in above-mentioned technical proposal is realized when computer program is executed by processor.
The embodiment of the present invention provides a kind of RSET interface realizing methods and device and electronic equipment and computer-readable storage
Medium.Wherein, REST interfaces are used to connect front end and backstage;The RSET interface realizing methods can include:Obtain front end demand
Data;Based on front end demand data, interface interchange parameter and interface return value are determined;Returned based on interface interchange parameter and interface
Value, the interactive operation between front end and backstage is determined according to REST specifications, so as to realize REST interfaces.With prior art phase
Than, the embodiment of the present invention is by taking above-mentioned technical proposal, due to realizing interface using REST specifications, so, can be by
The template that REST specifications are annotated as interface function, so as to according to interface annotation generation interface document.The interface document pair
All it is known for front end and backstage, it is easy to understand.Therefore, if front end is by ajax, (Ajax, one kind is asynchronous to be added
Carry and local refresh technique) call during REST interfaces, then can be in order to the communication between front end and backstage;Furthermore, it is possible to real
When online preview interface document, also achieve the separation of client and server, can individually handle each from client
Request, it is easy to repair failure, reduce the use of server resource, reduce interacting time between client and server
Number, also improves scalability.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
Obtain it is clear that or being emerged from by implementing the present invention.The purpose of the present invention and other advantages can by specification,
Specifically noted structure is realized and obtained in claims and accompanying drawing.
Certainly, any product or method for implementing the present invention it is not absolutely required to while reaching all the above excellent
Point.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
There is the accompanying drawing used required in technology description to be briefly described, it should be apparent that, drawings in the following description are only this
Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be with
Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is the schematic flow sheet of the RSET interface realizing methods according to the embodiment of the present invention;
Fig. 2 is the schematic flow sheet of the structure REST interfaces according to the embodiment of the present invention;
Fig. 3 is the structural representation that device is realized according to the RSET interfaces of the embodiment of the present invention;
Fig. 4 is the structural representation of the second determining module according to the embodiment of the present invention;
Fig. 5 is the structural representation of the electronic equipment according to the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made
Embodiment, belongs to the scope of protection of the invention.
Term explanation
Interface refers to be linked into another module applied by one, be also in computer system each submodule or
The part for interacting and interacting between subsystem.
RSET (Resource Representational State Transfer, the transfer of resource form of expression state) connects
Mouth is used for the interface interacted between client and server, is to need the one kind observed regular when building API.Wherein, resource is
Refer to data;The form of expression can be JSON, XML, JPEG etc.;State transfer can be realized by HTTP.REST interfaces pass through
Http protocol, URL (URL) and parameter, some service is accessed using customer end/server mode, one is completed
A little row service requests, are increased, are read, being updated, being deleted etc. and operated.REST interfaces can be for different platforms (for example:Android
Platform, apple platform) service is provided.In addition, not needing the platform of explicit front end for microblogging, wechat etc., REST interfaces also may be used
To provide service for it.
Front end refers to send the application program that request purpose sets up connection.Such as APP (application program) or website.Its
In, the APP includes the page.
Backstage, also referred to as rear end, refer to the application program for receiving to connect and being asked for transmission return information.For example:Database.
Above-mentioned front end and above-mentioned backstage are that comparatively, they can also mutually be changed.Above-mentioned front end and above-mentioned backstage
Connection can be set up by socket.
When framework refers to exploitation APP, the framework relevant with response processing with request processing.
Wherein, framework refers to the organizational form for the various resources that the various technologies being related in APP exploitations are possessed, example
Such as:File, database, HTTP (HTTP) requests etc..
Framework can be achieved by computing device.The computing device can include:The various physics for being used to transmit information
Part and/or logical block, the requirement that they can be restricted according to one group of given design parameter or performance, by hardware component
(for example:Processor, programmable logic controller (PLC)), the executable computer program that can be performed by various hardware componenies instruction (example
Such as:Firmware, software) or their any combination be achieved.Above-mentioned computing device can include but is not limited to individual calculus
Machine is (for example:Desktop computer, laptop computer, notebook computer), smart mobile phone, personal digital assistant (PDA), matchmaker
Body player or any other suitable communicator.
Framework can be run and be achieved by Web-browser.Wherein, Web-browser can by such as IE,
The Web-browser of Firefox (red fox), Opera (Ou Peng) or arbitrarily suitable, desktop computer version or mobile version gives
To realize.The Web-browser can with the computer programming language required by supporting frame, standard, world wide web protocols and/or
Technology.These computer programming languages, standard, world wide web protocols and/or technology include but is not limited to HTML (hypertext markup languages
Speech), XML (extensible markup language), Ajax (Ajax), Flash (animation), CSS (CSS) or other are suitable
When programming language, script or language based on VM (virtual machine).Web-browser can provide the base of user interface
Plinth, and can include:For such as JS (a kind of WWW programmed scripts language), VB, (visualization initiator's general symbol(s) refers to
Make code language) and/or other scripting programming languages language interpreter.Wherein, interpretive program real-time interpretation is based on browsing
Script, byte code collection or the language of device.
NameSpace refers to the method for encapsulating things, specifically, and it can be by related class, function and constant combination
To approach together.
In interface exploitation application, when developer's docking port of front end and backstage is unfamiliar with, especially docking port is advised
When being unfamiliar with terms of model, interface document, communication disorders can be caused between front end and backstage.Therefore, the embodiment of the present invention is carried
For a kind of RSET interface realizing methods.Fig. 1 schematically illustrates the flow of RSET interface realizing method steps.As shown in figure 1,
This method can be realized by step S100 to step S120.Wherein:
S100:Obtain front end demand data.
Wherein, front end demand data is related to the outside resource to be showed to APP.
S110:Based on front end demand data, interface interchange parameter and interface return value are determined.
Wherein, interface interchange parameter can by front end by HTTP (HTTP) method come calling interface.Interface
Call parameters can receive type, user name etc., and it can be defined according to actual conditions.The data of interface interchange parameter
Type can be character string, integer etc., but be not limited to this.Interface return value feeds back to front end by interface.Interface return value can
Think any type of data.
For example, interface return value thinks 0 or 1, wherein it is possible to define 0 expression operation failure, 1 represents to operate successfully;
Interface return value can also be 1001,1002,1003 etc., wherein it is possible to define 1001 expression parameter errors, 1002 represent user
Name is not present, and 1003 represent without the target that can be pushed.
Preferably, it is contemplated that the fluency interacted between front end and backstage, it can be encapsulated using fixed data format
Interface return value.
S120:Based on interface interchange parameter and interface return value, determined according to REST specifications between front end and backstage
Interactive operation, so as to realize REST interfaces.
Wherein, REST specifications define the mode for building interface.For example:(1) resource is specified using noun in URL;
The resource can be any one entity or information on network, for example, one section of text, a song, pictures etc.;(2)
The transfer of resource status is realized by verb in http protocol;(3) using certain form of expression client and server it
Between transmit resource, and the status information of server is transmitted by HTTP state codes;(4) in each request from client
To include all information required for server;(5) information that server is returned must mark whether to cache;(6) logarithm
According to select (acquisition), creat (establishment), delect (deletion) and update (renewal) operation correspond respectively to HTTP method
In get (acquisition), post (submission), delete (deletion) and put (renewal) operation, changed with the additions and deletions of complete paired data and look into behaviour
Make.Wherein, URL includes protocol name, hostname and catalogue and filename.
All things on network are all considered as resource by above-mentioned REST specifications.Each resource one unique resource of correspondence
Finger URL.Resource is operated by general connector interface, and various operations are stateless not change resource
Finger URL.That is, all resources all carry out resource access by identical interface.Wherein, stateless refers to that some is grasped
Make the operation independent of other resources.
The embodiment of the present invention is by taking above-mentioned technical proposal, due to realizing interface using REST specifications, so, can be with
The template that REST specifications are annotated as interface function, so as to according to interface annotation generation interface document.The interface document
All it is known for front end and backstage, it is easy to understand.Therefore, if front end is by Ajax, (Ajax, one kind is asynchronous
Loading and local refresh technique) call during REST interfaces, then can be in order to the communication between front end and backstage;Furthermore, it is possible to
Real-time online preview interface document, also achieves the separation of client and server, can individually handle each from client
The request at end, it is easy to repair failure, reduces the use of server resource, reduces interacting time between client and server
Number, also improves scalability.
In some optional embodiments, step S120 can specifically include:Returned based on interface interchange parameter and interface
Value, HyperText Preprocessor THINKPHP frameworks and its NameSpace mode, and build according to REST specifications realize front end with
The REST interfaces of interactive operation between backstage.
Wherein, THINKPHP frameworks be based on MVC (model-view-controller, model-view-controller) and
PHP (hypertext pretreatment language) Development Framework of object-oriented.THINKPHP frameworks can include complete application catalogue knot
Structure and entry file, and conducted interviews based on module and the mode operated, and application is performed using single entry file.Its
In, the access of entry file is by URL parameter is come analytic uniform and scheduling.The API demand data related to user's HTTP request
Application example is generated by entry file.The entry file can be accessed by browser.THINKPHP frameworks can apply to
Based in B/S (browser/server), the environment of C/S (client/server) structure, and developed based on http protocol
Management.
Using REST methods, it is necessary to judge request type and resource type in THINKPHP frameworks.Therefore, exist
In Rest operating methods, $ this- can be used>Type methods obtain the resource type of current accessed, use $ this->method
Method obtains current request type.Further, it is also possible to call Restful operating methods automatically in the following manner:Operation name _
Submit type _ resource suffix, operation name _ resource suffix, operation name _ submission type.Wherein, operation name for example can be reading and writing
Deng.Type is submitted such as can be GET types, POST types.Resource suffix for example can be pdf.
The present embodiment can be defined and be loaded class library files by NameSpace.Therefore, can be in reality by NameSpace
Between title defined in being avoided during existing REST interfaces and class/function/constant inside PHP or third party's class/function/constant
Conflict, so as to improve the readability of REST interface codes.
, can be by non-limiting title or the class name without prefix, qualified name or before containing during implementing
The modes such as the title sewed, the title for containing global prefixes operator use element in NameSpace.
By taking the entitled foo of file as an example, file path is foo::Exemplified by staticmethod (), it is assumed that NameSpace is:
currentnamespace.If by non-limiting title come using the element in NameSpace, foo will be resolved to
Currentnamespace foo, it is represented using the file f oo in NameSpace currentnamespace;If file road
Footpath be subnamespace foo::Staticmethod (), uses the element in NameSpace, then by qualified name
Foo can be resolved to currentnamespace subnamespace foo;If file path for
currentnamespace\foo::Staticmethod (), then foo be always resolved in code word name
currentnamespace\foo。
The embodiment of the present invention is by taking above-mentioned technical proposal, due to THINKPHP frameworks to be combined with REST specifications
Interface is realized, it is achieved thereby that the automatic checking that THINKPHP frameworks are possessed, caching mechanism, project compiling, routing function
The features such as the unified interface with REST specifications, the HTTP method using standard be combined the features such as carry out operating resource.So, can be with
The template that the specification of THINKPHP frameworks and REST specifications are annotated as interface function, is generated so as to be annotated according to interface
Interface document, moreover, the interface document can support additions and deletions change to look into and function of search, moreover it is possible to real-time online preview.Interface document
It can include:Usage scenario, request method, version number, required parameter and returned data etc..Pass through interface document, it will be appreciated that
The function that the interface is realized.So, the interface document is all known for front end and backstage, is readily appreciated.Therefore,
The present embodiment has conveniently realized the real-time communication between front end and backstage;Furthermore, it is possible to real-time online preview interface document, also
The separation of client and server is realized, each request from client can be individually handled, it is easy to repair failure, dropped
The low use of server resource, reduces the interaction times between client and server, also improves scalability.
In some optional embodiments, THINKPHP frameworks can include REST controllers;As shown in Fig. 2 being based on connecing
Mouth call parameters and interface return value, THINKPHP frameworks and its NameSpace mode, and build REST according to REST specifications
The step of interface, can further include:
S200:Based on interface interchange parameter and interface return value and THINKPHP frameworks, interface access controller is built.
Wherein, in THINKPHP frameworks controller and its operation can be accessed and performed by URL parameter.
THINKPHP frameworks are also considered as the Web frameworks (Web Framework) based on controller.
In the present embodiment, access controller can utilize THINKPHP frameworks, be defined by NameSpace.Then, it will connect
Mouth call parameters and interface return value configuration are in access controller.
S201:Interface access controller is inherited into REST controllers, the first controller is obtained.
Wherein, as interchangeable embodiment, REST controllers can also be resouce controller.
By inheriting REST controllers, interface access controller can obtain the characteristic of REST controllers.For example:Interface is visited
Ask that controller can support resource type automatic detection and request type automatic detection and REST operating methods, and can also permit
The resource type and default request type and default resource type of request type list, request and output are set perhaps.
S202:In the first controller, REST property parameters and REST routes are defined according to REST specifications, second is obtained
Controller;Wherein, REST property parameters and REST route the operation for realizing REST interfaces.
Wherein, REST property parameters are used to determine the request type list of REST permissions, request type, allow the money of request
Source Type list, resource type, the resource type list for allowing output etc..The definition being route by REST can operate REST
Method is bound together with some request type and resource type.REST routes can be joined by the route in THINKPHP frameworks
Count to define.
In REST operating process is specifically described, operation is described using HTTP method, that is, REST is operated
Select (acquisition), creat (establishment), delect (deletion) and update (renewal) operations are corresponded respectively in HTTP method
Get (acquisition), post (submission), delete (deletion) and put (renewal) operations are realized.
As an example, the form of HTTP request message is:Request message=request row physical contents.Wherein, ask row=
Method request URL HTTP version numbers physical contents.Wherein, method includes GET methods, POST method, HEAD methods etc..Thus,
If be defined as below:GET/users, then it represents that list the operation of all users.For another example, if be defined as below:
POST/users, then it represents that the operation of one new user of insertion., can be by these Operation Definitions in control in specific implementation process
In device processed.
S203:API functional units are encapsulated in NameSpace;Wherein, API functional units are relative with front end demand data
Should.
Wherein, API functional units be such as can be authentication module, interface base class, document automatically-generating module, but never
It is limited to this.
NameSpace can include class, interface, function and constant etc..So, can be by authentication module, interface base class, text
Shelves the function such as automatically generate and are encapsulated in NameSpace.
By taking class as an example, in THINKPHP frameworks, the NameSpace where being defined to class libraries, and the road of the NameSpace
Footpath is consistent with the catalogue of class library files, then can just realize the automatic loading of class.
S204:The NameSpace for being packaged with API functional units is configured in second controller, the 3rd controller is obtained,
And the THINKPHP frameworks that the 3rd controller will be carried, it is defined as RSET interfaces.
The embodiment of the present invention is by taking above-mentioned technical proposal, due to THINKPHP frameworks to be combined with REST specifications
Realize interface.Thus the features such as automatic checking that THINKPHP frameworks is possessed, caching mechanism, project compiling, routing function
Unified interface with REST specifications, it is combined the features such as carry out operating resource using the HTTP method of standard.So, can be by
The template that specification defined in THINKPHP frameworks and REST specifications are annotated as interface function, so as to be annotated according to interface
Interface document is generated, moreover, the interface document can support additions and deletions change to look into and function of search, moreover it is possible to real-time online preview.Interface
Document can include:Usage scenario, request method, version number, required parameter and returned data etc.., can be with by interface document
Understand the function that the interface is realized.So, interface document is all known for front end and backstage, it is easy to understood.Cause
This, the present embodiment has conveniently realized the real-time communication between front end and backstage.In addition, the present embodiment is due to using REST rule
Model, also achieves the separation of client and server, can individually handle each request from client, it is easy to repair event
Barrier, reduces the use of server resource, reduces the interaction times between client and server, also improve expansible
Property.
In order to solve how to be easy to the technical problem that front end is linked up with backstage, based on above method embodiment identical skill
Art is conceived, and the embodiment of the present invention also provides a kind of resource form of expression state transfer RSET interfaces and realizes device.The RSET interfaces
Realize that device embodiment can perform above-mentioned RSET interface realizing methods embodiment.The REST interfaces can be used for connection front end with
Backstage.As shown in figure 3, the RSET interfaces realize that device can include:Acquisition module 32, the first determining module 34 and second are determined
Module 36.Wherein, acquisition module 32 is used to obtain front end demand data.First determining module 34 is used to be based on front end demand number
According to determining interface interchange parameter and interface return value.Second determining module 36 is used to return based on interface interchange parameter and interface
Value, the interactive operation between front end and backstage is determined according to REST specifications, so as to realize REST interfaces.
In the present embodiment, due to the second determining module 36 using REST specifications and with acquisition module 32, the first determining module
34 synergies realize REST interfaces, so, the template that REST specifications can be annotated as interface function, so as to by
According to interface annotation generation interface document.The interface document is all known for front end and backstage, it is easy to understood.Therefore,
If front end calls the embodiment of the present invention to be realized by ajax (Ajax, a kind of Asynchronous loading and local refresh technique)
REST interfaces when, then can be in order to the communication between front end and backstage;Furthermore, it is possible to real-time online preview interface document, this
Inventive embodiments RSET interfaces realize that the REST interfaces that device is realized realize the separation of client and server, can be independent
Handle each request from client, it is easy to repair failure, reduce the use of server resource, reduce client with
Interaction times between server, also improve scalability.
In some optional embodiments, the second determining module specifically can be used for:Based on interface interchange parameter and interface
Return value, HyperText Preprocessor THINKPHP frameworks and its NameSpace mode, and according to REST specifications, structure realizes front end
The REST interfaces of interactive operation between backstage.
In some optional embodiments, THINKPHP frameworks include REST controllers;As shown in figure 4, second determines mould
Block can specifically include:Construction unit 41, succession unit 42, definition unit 43, encapsulation unit 44 and dispensing unit 45.Wherein,
Construction unit 41 is used to be based on interface interchange parameter and interface return value and THINKPHP frameworks, builds interface access control
Device.Inheriting unit 42 is used to interface access controller inheriting REST controllers, obtains the first controller.Definition unit 43 is used for
In the first controller, REST property parameters and REST routes are defined according to REST specifications, second controller is obtained;Wherein,
REST property parameters and REST route the operation for realizing REST interfaces.Encapsulation unit 44 is used to encapsulate API functional units
In NameSpace;Wherein, API functional units are corresponding with front end demand data.Dispensing unit 45 is used to that API work(will to be packaged with
The NameSpace of energy unit is configured in second controller, obtains the 3rd controller, and will carry the 3rd controller
THINKPHP frameworks, are defined as RSET interfaces.
In the present embodiment, due to construction unit 41, unit 42, definition unit 43, encapsulation unit 44 and dispensing unit are inherited
45 are combined THINKPHP frameworks with REST specifications to realize interface.Thus tested what THINKPHP frameworks possessed automatically
The unified interface of the features such as card, caching mechanism, project compiling, routing function and REST specifications, the HTTP method using standard
The features such as operating resource, is combined.So, specification defined in THINKPHP frameworks and REST specifications can be regard as interface letter
The template of number annotation, so as to according to interface annotation generation interface document, moreover, the interface document can support additions and deletions change to look into
And function of search, moreover it is possible to real-time online preview.Interface document can include:Usage scenario, request method, version number, request ginseng
Number and returned data etc..Pass through interface document, it will be appreciated that the function that the interface is realized.So, interface document is for front end
With being all known for backstage, it is easy to understand.Therefore, the present embodiment has conveniently realized the real-time ditch between front end and backstage
It is logical.In addition, the present embodiment also achieves the separation of client and server due to using REST specifications, it can individually handle every
One request from client, it is easy to repair failure, reduces the use of server resource, reduces client and server
Between interaction times, also improve scalability.
In order to solve the technical problem for how being easy to front end to be linked up with backstage, the embodiment of the present invention also provides a kind of electronics and set
It is standby.As shown in figure 5, the electronic equipment can include processor 51, communication interface 52, memory 53 and communication bus 54, wherein,
Processor 51, communication interface 52 and memory 53 complete mutual communication by communication bus 54;Memory 53 is used to deposit
Computer program.When processor 51 is used to perform the program deposited on memory 53, the side in above method embodiment is realized
Method step.
The communication bus that above-mentioned electronic equipment is mentioned can be Peripheral Component Interconnect standard (Peripheral Component
Interconnect, PCI) bus or EISA (Extended Industry Standard
Architecture, EISA) bus etc..The communication bus can be divided into address bus, data/address bus, controlling bus etc..For just
Only represented in expression, Fig. 5 with a thick line, it is not intended that only one bus or a type of bus.
The communication that communication interface is used between above-mentioned electronic equipment and other equipment.
Memory can include random access memory (Random Access Memory, RAM), can also include non-easy
The property lost memory (non-volatile memory, NVM), for example, at least one magnetic disk storage.Optionally, memory may be used also
To be storage device that at least one is located remotely from aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit,
Abbreviation CPU), network processing unit (Ne twork Processor, NP) etc.;It can also be digital signal processor (Digital
Signal Processing, DSP), application specific integrated circuit (Applica tion Specific Integrated Circuit,
ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other FPGAs
Device, discrete gate or transistor logic, discrete hardware components.
In order to solve the technical problem for how being easy to front end to be linked up with backstage, the embodiment of the present invention also provides a kind of computer
Readable storage medium storing program for executing, it is characterised in that computer-readable recording medium internal memory contains computer program, computer program is processed
Device realizes the method and step in the above method embodiment when performing.
Above computer readable storage medium storing program for executing includes but is not limited to random access memory (RAM), dynamic randon access and deposited
Reservoir (DRAM), static RAM (SRAM), read-only storage (ROM), programmable read only memory (PROM), can
Erasable programmable read only memory (EPROM), EEPROM (EEPROM), flash memory are (for example, NOR-type
Flash memory or NAND-type flash memory), Content Addressable Memory (CAM), polymer memory (for example, ferroelectric polymer memory),
Phase transition storage, ovonic memory, silicon-oxide-nitride silicon-silica-silicon (Silicon-Oxide-
Nitride-Oxide-Silicon, SONOS) memory, magnetic card or light-card, also or other any suitable types calculating
Machine readable storage medium storing program for executing.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality
Body or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or deposited between operating
In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Nonexcludability is included, so that process, method, article or equipment including a series of key elements not only will including those
Element, but also other key elements including being not expressly set out, or also include being this process, method, article or equipment
Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that
Also there is other identical element in process, method, article or equipment including the key element.
Each embodiment in this specification is described by the way of related, identical similar portion between each embodiment
Divide mutually referring to what each embodiment was stressed is the difference with other embodiment.It is real especially for system
Apply for example, because it is substantially similar to embodiment of the method, so description is fairly simple, related part is referring to embodiment of the method
Part explanation.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all
Any modification, equivalent substitution and improvements made within the spirit and principles in the present invention etc., are all contained in protection scope of the present invention
It is interior.
Claims (8)
1. a kind of resource form of expression state shifts RSET interface realizing methods, wherein, the REST interfaces are used to connect front end
With backstage;Characterized in that, methods described includes:
Obtain front end demand data;
Based on the front end demand data, interface interchange parameter and interface return value are determined;
Based on the interface interchange parameter and the interface return value, the front end and the backstage are determined according to REST specifications
Between interactive operation, so as to realize the REST interfaces.
2. according to the method described in claim 1, it is characterised in that described to be returned based on the interface interchange parameter and the interface
Value is returned, the interactive operation between the front end and the backstage is determined according to REST specifications, so that the REST interfaces are realized,
Specifically include:
It is empty based on the interface interchange parameter and the interface return value, HyperText Preprocessor THINKPHP frameworks and its name
Between mode, and according to REST specifications, build the REST interfaces for realizing the interactive operation between the front end and the backstage.
3. method according to claim 2, it is characterised in that the THINKPHP frameworks include REST controllers;It is described
Based on the interface interchange parameter and the interface return value, HyperText Preprocessor THINKPHP frameworks and its NameSpace side
Formula, and the REST interfaces are built according to REST specifications, specifically include:
Based on the interface interchange parameter and the interface return value and the THINKPHP frameworks, interface access control is built
Device;
The interface access controller is inherited into the REST controllers, the first controller is obtained;
In first controller, REST property parameters and REST routes are defined according to the REST specifications, second is obtained
Controller;Wherein, the REST property parameters and the REST route the operation for realizing the REST interfaces;
API functional units are encapsulated in NameSpace;Wherein, the API functional units are relative with the front end demand data
Should;
The NameSpace for being packaged with the API functional units is configured in the second controller, the 3rd controller is obtained, and
The THINKPHP frameworks of the 3rd controller will be carried, be defined as the RSET interfaces.
4. a kind of RSET interfaces realize device, wherein, the REST interfaces are used to connect front end and backstage;Characterized in that, institute
Stating device includes:
Acquisition module, for obtaining front end demand data;
First determining module, for based on the front end demand data, determining interface interchange parameter and interface return value;
Second determining module, for based on the interface interchange parameter and the interface return value, being determined according to REST specifications
Interactive operation between the front end and the backstage, so as to realize the REST interfaces.
5. device according to claim 4, it is characterised in that second determining module specifically for:
It is empty based on the interface interchange parameter and the interface return value, HyperText Preprocessor THINKPHP frameworks and its name
Between mode, and according to REST specifications, build the REST interfaces for realizing the interactive operation between the front end and the backstage.
6. device according to claim 5, it is characterised in that the THINKPHP frameworks include REST controllers;It is described
Second determining module is specifically included:
Construction unit, for based on the interface interchange parameter and the interface return value and the THINKPHP frameworks, structure
Build interface access controller;
Unit is inherited, for the interface access controller to be inherited into the REST controllers, the first controller is obtained;
Definition unit, in first controller, REST property parameters and REST to be defined according to the REST specifications
Route, obtains second controller;Wherein, the REST property parameters and the REST are route for realizing the REST interfaces
Operation;
Encapsulation unit, for API functional units to be encapsulated in NameSpace;Wherein, the API functional units and the front end
Demand data is corresponding;
Dispensing unit, for the NameSpace for being packaged with the API functional units to be configured in the second controller, is obtained
3rd controller, and the THINKPHP frameworks that will carry the 3rd controller, are defined as the RSET interfaces.
7. a kind of electronic equipment, it is characterised in that including processor, communication interface, memory and communication bus, wherein, it is described
Processor, the communication interface and the memory complete mutual communication by the communication bus;
The memory, for depositing computer program;
The processor, for performing during the program deposited on memory, realizes any described method steps of claim 1-3
Suddenly.
8. a kind of computer-readable recording medium, it is characterised in that the computer-readable recording medium internal memory contains computer
Program, the computer program realizes claim 1-3 any described method and steps when being executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710536277.XA CN107301137A (en) | 2017-07-04 | 2017-07-04 | RSET interface realizing methods and device and electronic equipment and computer-readable recording medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710536277.XA CN107301137A (en) | 2017-07-04 | 2017-07-04 | RSET interface realizing methods and device and electronic equipment and computer-readable recording medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107301137A true CN107301137A (en) | 2017-10-27 |
Family
ID=60135636
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710536277.XA Pending CN107301137A (en) | 2017-07-04 | 2017-07-04 | RSET interface realizing methods and device and electronic equipment and computer-readable recording medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107301137A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108270858A (en) * | 2018-01-15 | 2018-07-10 | 郑州云海信息技术有限公司 | A kind of private cloud framework and its data processing method based on API gateway |
CN109683886A (en) * | 2018-11-28 | 2019-04-26 | 国云科技股份有限公司 | A kind of diversification interface document generation method |
CN109815009A (en) * | 2018-12-28 | 2019-05-28 | 周口师范学院 | Scheduling of resource and optimization method under a kind of CSP |
CN110704030A (en) * | 2019-09-26 | 2020-01-17 | 北京达佳互联信息技术有限公司 | Interface configuration information generation method and device, electronic equipment and storage medium |
CN111367199A (en) * | 2018-12-26 | 2020-07-03 | 中国科学院沈阳自动化研究所 | Digital quantity instrument configuration method based on REST function packaging |
CN112216337A (en) * | 2020-09-11 | 2021-01-12 | 深圳市金泰克半导体有限公司 | Firmware parameter detection method and device and firmware setting method |
CN112286508A (en) * | 2020-11-09 | 2021-01-29 | 无锡新思联信息技术有限公司 | RestAPI interface design method for internet of things resource operation |
CN113489672A (en) * | 2021-05-21 | 2021-10-08 | 浙江大学 | Network sniffing-based REST interface specification packaging system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1466051A (en) * | 2002-07-03 | 2004-01-07 | 联想(北京)有限公司 | Method for realizing data interaction between different systems |
CN104881318A (en) * | 2015-05-07 | 2015-09-02 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
-
2017
- 2017-07-04 CN CN201710536277.XA patent/CN107301137A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1466051A (en) * | 2002-07-03 | 2004-01-07 | 联想(北京)有限公司 | Method for realizing data interaction between different systems |
CN104881318A (en) * | 2015-05-07 | 2015-09-02 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
Non-Patent Citations (1)
Title |
---|
ROY THOMAS FIELDING: "架构风格与基于网络应用软件的架构设计", 《HTTP://WWW.ICS.UCI.EDU/~FIELDING/PUBS/DISSERTATION/TOP.HTM》 * |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108270858A (en) * | 2018-01-15 | 2018-07-10 | 郑州云海信息技术有限公司 | A kind of private cloud framework and its data processing method based on API gateway |
CN109683886A (en) * | 2018-11-28 | 2019-04-26 | 国云科技股份有限公司 | A kind of diversification interface document generation method |
CN111367199A (en) * | 2018-12-26 | 2020-07-03 | 中国科学院沈阳自动化研究所 | Digital quantity instrument configuration method based on REST function packaging |
CN109815009A (en) * | 2018-12-28 | 2019-05-28 | 周口师范学院 | Scheduling of resource and optimization method under a kind of CSP |
CN110704030A (en) * | 2019-09-26 | 2020-01-17 | 北京达佳互联信息技术有限公司 | Interface configuration information generation method and device, electronic equipment and storage medium |
CN112216337A (en) * | 2020-09-11 | 2021-01-12 | 深圳市金泰克半导体有限公司 | Firmware parameter detection method and device and firmware setting method |
CN112216337B (en) * | 2020-09-11 | 2024-03-29 | 深圳市金泰克半导体有限公司 | Firmware parameter detection method, device and firmware setting method |
CN112286508A (en) * | 2020-11-09 | 2021-01-29 | 无锡新思联信息技术有限公司 | RestAPI interface design method for internet of things resource operation |
CN113489672A (en) * | 2021-05-21 | 2021-10-08 | 浙江大学 | Network sniffing-based REST interface specification packaging system |
CN113489672B (en) * | 2021-05-21 | 2022-05-17 | 浙江大学 | Network sniffing-based REST interface specification packaging system |
WO2022242415A1 (en) * | 2021-05-21 | 2022-11-24 | 浙江大学 | Rest interface specification packaging system based on network sniffing |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107301137A (en) | RSET interface realizing methods and device and electronic equipment and computer-readable recording medium | |
Subramanian et al. | Hands-On RESTful API Design Patterns and Best Practices: Design, develop, and deploy highly adaptable, scalable, and secure RESTful web APIs | |
KR102243793B1 (en) | Method and apparatus for code virtualization and remote process call generation | |
US9122657B2 (en) | Webpage display system leveraging OSGI | |
Huang et al. | Programming situational mobile web applications with cloud-mobile convergence: an internetware-oriented approach | |
CN109656538A (en) | Generation method, device, system, equipment and the medium of application program | |
CN108287839A (en) | A kind of page loading method and equipment | |
CN110083383A (en) | Browser style compatibility method, device, computer equipment and storage medium | |
CN102023856A (en) | Method for outputting and operating data at server in formatting way according to demands of user | |
CN103443763B (en) | Comprise to connect the ISA Bridge of the support called rewriteeing virtual function | |
US9614901B2 (en) | Data infrastructure for providing interconnectivity between platforms, devices, and operating systems | |
CN106569856A (en) | Method and device of loading application view resource file | |
US11023558B1 (en) | Executing functions on-demand on a server utilizing web browsers | |
Colombo-Mendoza et al. | MobiCloUP!: a PaaS for cloud services-based mobile applications | |
CN110750243A (en) | Project code development method and system | |
CN109460546A (en) | List generation method, device and electronic equipment | |
CN110213105A (en) | It is a kind of cross-platform micro- using creation method | |
Klauzinski et al. | Mastering JavaScript Single Page Application Development | |
CN106648569A (en) | Target serialization achieving method and device | |
CN108021564A (en) | A kind of method and apparatus of page reorientation | |
CN110059278A (en) | Web page configuration method, server and computer readable storage medium | |
Bojinov | RESTful Web API Design with Node. js 10: Learn to create robust RESTful web services with Node. js, MongoDB, and Express. js | |
CN101876998A (en) | Method and system for editing data | |
US10606569B2 (en) | Declarative configuration elements | |
CN107077484B (en) | Generating a web browser view of an application |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20171027 |