restful

RESTful on Play! framework

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We are planning a project primarily serving content to mobile apps, but need to have a website. My question is whether is makes sense to use Jersey or Restlet to develop REST APIs for our mobile apps, and then use Play! to serve the website. Or does it make more sense to just use Play! to do it all? If so, how to do REST with Play! framework? 回答1: As per request, a simple REST-like approach. It works almost the same way Codemwncis' solution works but uses the Accept header for content negotiation. First the routes file: GET /user/{id}

Design RESTful query API with a long list of query parameters

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So, I need to design a RESTful query API, that returns a set of objects based on a few filters. The usual HTTP method for this is GET. The only problem is, it can have at least a dozen filters, and if we pass all of them as query parameters, the URL can get quite long (long enough to be blocked by some firewall). Reducing the numbers of parameters is not an option. One alternative I could think of is to make use of the POST method on the URI and send the filters as part of the POST body. Is this against being RESTfull (Making a POST call to

Sending binary data to (Rails) RESTful endpoint via JSON/XML?

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am currently putting together a rails-based web application which will only serve and receive data via json and xml. However, some requirements contain the ability to upload binary data (images). Now to my understanding JSON is not entirely meant for that... but how do you in general tackle the problem of receiving binary files/data over those two entrypoints to your application? 回答1: I suggest encoding the binary data in something like base64. This would make it safe to use in XML or JSON format. http://en.wikipedia.org/wiki/Base64 回答2:

基于MVC的RESTful风格的实现

混江龙づ霸主 提交于 2019-12-03 06:49:32
基于 MVC 的 RESTful 风格的实现 1. RESTful 风格阐述 REST 服务是一种 ROA (Resource-Oriented Architecture,面向资源的架构)应用。主要特点是方法信息存在于 HTTP 协议的方法中( GET , POST , PUT , DELETE ),作用域存在于 URL 中。例如,在一个获取设备资源列表的 GET 请求中,方法信息是 GET ,作用域信息是URI种包含的对设备资源的过滤、分页和排序等条件 良好的 REST API 不需要任何文档 1.1 REST 风格资源路径 REST 风格的资源路径设计是面向资源的, 资源的名称 应该是准确描述该资源的 名词 。 资源路径概览: sheme://host:port/path?queryString 例: http://localhost:8080/bywlstudio/users/user?username=xiuer 1.2 HTTP 方法 GET 用于 读取 、 检索 、 查询 、 过滤 资源 PSOT 用于 创建 一个资源 PUT 用于 修改 、 更新 资源、 创建客户端维护主键信息的资源 DELETE 用于 删除 资源 资源地址和 HTTP 方法结合在一起就可以实现对资源的完整定位 1.3 RESTful 风格 API 设计

restful 笔记一

流过昼夜 提交于 2019-12-03 06:27:51
restful:webService,与传统webservice相比,http传输方式为json 或者xml,而传统rpc-webservice(soap协议)只采用xml方式。 1、面向资源,各个资源之间是不存在关联的,http的方法用到 post get put delete。 restful:说来道去只有一个思想就是让你的api尽量好理解。 restful是一种思想,理念,你不要被它束缚。 restful处理静态资源:静态资源还是放在静态的服务器上比较好,如果放在web app的服务器里,一个大的资源文件使用http加载的时候很可能拖垮整个服务器。(文件上传下载应该从业务的api中剥离,业务的api应该只传递文件地址) 来源: oschina 链接: https://my.oschina.net/u/235020/blog/794926

RESTful web service: java.lang.NullPointerException service.AbstractFacade.findAll

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I created a simple XML web service using NetBeans 7's "RESTful Web Services from Database..." wizard. At this point, I want to publish a list of users from the associated mySQL database. When I attempt to access the service via its URL (http://localhost:8080/database/resources/users), I get an error that reads "java.lang.NullPointerException". The stack trace: service.AbstractFacade.findAll(AbstractFacade.java:41) service.UserFacade.findAll(UserFacade.java:51) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect

Restful MVC Web Api Inheritance

匿名 (未验证) 提交于 2019-12-03 02:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im building myself an asp.net mvc 4 web api I've been through the Microsoft videos and I think they are good. Http Verbs are used. Resources are nouns, it's dandy with repositories, etc. But one thing really bugs me I'm under the impression that this GET http://www.myurl.com/api/sellers/{id}/products is restful and GET http://www.myurl.com/api/products?$filter = sellerID eq {id} is not. All I see in what I've read about the new web api is the former latter. Is there native support for the latter former? If not, is there a way to do it

Node.js testing RESTful API (vows.js?)

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I could really do with some advice on testing a RESTful api I created in node.js. There are a plethora of frameworks out there and I am at a loss. My testing knowledge isn't good enough generally which is why I am trying to write these tests. I've tried vows.js which seems nice but I couldn't work out how to incorporate the testing of my API, I need some sort of client. An example of a simple post to test a login system is all I need to get going. 回答1: Update 6 months later vows-is sucks. use mocha Original Updated with vow-is code Here's

使用 Spring Boot 构建 RESTful API

若如初见. 提交于 2019-12-03 02:54:48
1. 使用 Idea 创建 Spring Initializer 项目 在创建项目的对话框中添加 Web 和 Lombok,或者建立项目后在 pom.xml 中添加依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> 2. 使用注解构建 RESTful API 此处没有使用数据库,用 ArrayList 作为操作对象。 创建一个实体类,作为 API 操作的对象 package top.cloudli.demo.model; import lombok.AllArgsConstructor; import lombok.Data; @Data @AllArgsConstructor public class Character { private int id; private String name; private String racial;

Spring Security HTTP Basic for RESTFul and FormLogin (Cookies) for web - Annotations

匿名 (未验证) 提交于 2019-12-03 02:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In Specific I want to have HTTP Basic authentication ONLY for a specific URL pattern. In Detail I'm creating an API interface for my application and that needs to be authenticated by simple HTTP basic authentication . But other web pages should not be using HTTP basic but rather a the normal form login. Current Configuration - NOT Working @Override protected void configure(HttpSecurity http) throws Exception { http //HTTP Security .csrf().disable() //Disable CSRF .authorizeRequests() //Authorize Request Configuration .antMatchers("/connect/*