简体   繁体   English

RESTful for Ruby on Rails

[英]RESTful for Ruby on Rails

I am currently managing a backoffice made in Ruby on Rails. 我目前正在管理Ruby on Rails的后台。 I need to receive a .zip file from another Rails-based application with some configurations in xml. 我需要从另一个具有XML配置的基于Rails的应用程序接收一个.zip文件。 For that, I've been asked to create a RESTful interface which makes available an URL, that will be used by the other application to deploy the zip file in it. 为此,我被要求创建一个RESTful接口,该接口提供一个URL,其他应用程序将使用该URL在其中部署zip文件。 I know I'll have to use POST method. 我知道我必须使用POST方法。 I've tried the Sinatra gem, and I've tried using Webrick. 我尝试过Sinatra宝石,也尝试过使用Webrick。 I was able to open some port and render my address with Sinatra. 我能够打开一些端口,并在Sinatra上显示我的地址。 With Webrick, I was able to open some listening port, but it collided somehow with my rails app. 使用Webrick,我可以打开一些侦听端口,但是它与我的Rails应用程序发生了某种冲突。 Now, I'm using Net::HTTP class, and generating a request and response. 现在,我正在使用Net :: HTTP类,并生成请求和响应。 I am not sure of what I'm doing, though. 不过,我不确定自己在做什么。 My code: 我的代码:

http = Net::HTTP.new("someURL")
request = Net::HTTP::Post.new("/deployURL")
response = http.request(request)

Anyone has a tip on which steps to follow, and what would be the easiest implementation? 任何人都提示要遵循哪些步骤,最简单的实现是什么?

Thanks in advance. 提前致谢。

you can use GrapeApi for building restful api . 您可以使用GrapeApi来构建Restful API。 https://github.com/intridea/grape https://github.com/intridea/grape

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM