servicestack

The simplest example of Knockback js working with a RESTful webservice such as ServiceStack?

。_饼干妹妹 提交于 2019-12-03 00:31:16
I am looking for a VERY simple example that shows wiring up Knockback code to a backbone model that connects via RESTful service. I am using ServiceStack|c# backend. All of the links below are too complicated and use localStore rather than a RESTful service via url. I also prefer to see examples in Javascript not CoffeeScript. My example url is something like localhost/entities where hitting this will cause the RESTful webservice to return all of the entities. Hitting it with localhost/entity/1 would return the entity with an Id of 1. _http://kmalakoff.github.com/knockback/index.html _https:/

Updating Service Stack Redis List

不打扰是莪最后的温柔 提交于 2019-12-03 00:08:41
Is there a correct way to update a IRedisList? With the sample code below, I can modify it to remove the list, update the pizza and the re-add the list, but that feels wrong. The command line documentation is pretty thourough, but it's a much bigger project than I though and I'm not entirely sure where to start looking. public void UpdatePizza(Pizza pizza) { using (var redisClient = new RedisClient(Host, Port)) { IRedisTypedClient<Pizza> redis = redisClient.As<Pizza>(); IRedisList<Pizza> pizzas = redis.Lists["pizzas:live"]; var toUpdate = pizzas.First(x => x.Id == pizza.Id); toUpdate.State =

Stop Fluent Validation on first failure

蓝咒 提交于 2019-12-02 22:52:14
i'm defining a validation for my Request objects. I would like the validator to stop on the very first failure, not only the one on the same chain. In the example below, if my TechnicalHeader object is null, i get a NullReference exception when the validation reaches the rule for TechnicalHeader.MCUserid . In poor words, i would like to do a conditional validation over the last three rules in the code below, according to the result of the first rule using System; using ServiceStack.FluentValidation; using MyProj.Services.Models; namespace MyProj.Services.BaseService.Validators { public class

How to consume a file with a ServiceStack client

时光毁灭记忆、已成空白 提交于 2019-12-02 19:27:20
I am trying to use ServiceStack to return a file to a ServiceStack client in a RESTful manner. I have read other questions on SO ( here and here ) which advise using HttpResult and a FileInfo object or MemoryStream to allow the ContentType header to be changed to the relevant file type. This works for me when I call the service via a browser, the correct file automatically starts to download. How do I consume the file using one of the ServiceStack clients though? I'm using a Request DTO and trying to return using something similar to return new HttpResult(new FileInfo("file.xml"), asAttachment

How to use Servicestack Authentication with Active Directory/Windows Authentication?

穿精又带淫゛_ 提交于 2019-12-02 19:00:49
I am creating a secure (SSL) public service where the users credentials reside in Active Directory. I want to leverage ServiceStack's Authentication and have read over the wiki article . I already have code written to verify the user credentials with AD. I have a few questions. Which Auth provider do I use? Credentials, Basic Auth or Custom? The service requires SSL so Basic Auth would be safe, however passwords would be encrypted for added safety. Do I still need to store the UserAuth and cache the AuthUserSession? Will the monotouch client support authentication? Update 2: I did end up

ServiceStack 项目实例 003 建议的文件结构定义及服务类说明

半城伤御伤魂 提交于 2019-12-02 18:40:48
在我们的SS项目中, 建议的文件结构 如下: 需要的最基本的文件包含三个文件, 1 服务文件 :其中包含有入口类、出口类定义和服务类的定义,入口类是HTTP 请求request时候使用的类,出口类是HTTP 相应中使用的类,服务类中会调用入口类和出口类,关于入口类出口类和服务类的说明见下文。 2 实体类文件: 定义数据库相关的实体类,在SS中,实体类既可用作入口类,也可作为出口类。 3 数据访问类文件: 定义数据库操作的功能函数,这些功能函数会使用实体类文件中的类定义来映射数据库表,实体类文件中的类文件一般为DTO类,同时被服务文件和数据访问文件使用。 服务类文件可以根据需要分解为多个,比如一个资讯管理系统包含有类别管理 文章管理 新闻管理 下载管理 专题管理 , 就可以将这几个功能模块分别对应一个服务文件, 示例如下: CategoryService.cs ArticleService.cs NewsService.cs DownloadService.cs SpecialService.cs 入口类、出口类和实体类在对外服务中的用处。 入口类是数据传入的接口类,出口类是数据输出的接口类,实体类既可以作为入口类也可以作为出口类。 一般的应用情况是: 添加和修改数据时 入口类为实体类,封装传入的表单数据; 出口类为简单类(POCO型),作为操作状态的返回信息,如是否操作成功 列表

ServiceStack 项目实例 002 REST服务与客户端模式

为君一笑 提交于 2019-12-02 18:12:21
ServiceStack框架提供三种模式的服务接口实现, REST 、Client 以及和WCF相兼容的SOAP WebService ,这三种模式统称WebService,目前对于移动平台和云服务火爆的情形下,最为普及的是REST模式。 WebService常用连接模式: REST Client SOAP WebService 在不同模式下,可以使用不同的数据(流)格式,最为常用的是XML 、JSON , 主要使用在REST模式下,此外还支持JSV, CSV 以及SOAP格式的数据。 XML JSON JSV CSV SOAP 在前文中提到启动服务(SS项目),这种服务是一种无界面的,对外仅提供数据服务,通过一套自定义的API访问,在大型网站广为使用,比如微信、微博、淘宝及人人网、各种网盘开发API等。 SS中,客户端连接到服务端的方式主要有两种,通过REST方式或者Client方式,初始化客户端是相同的 : 1 var service = new JsvServiceClient( "http://localhost:2790/" ); 通过REST方式访问服务: 1 2 var storyResponses = service.Post<List<NewsResponse>>( "newslist" , new NewsAll() { cid=0 }); 其中service

How do you implement authentication in servicestack.net

放肆的年华 提交于 2019-12-02 17:41:27
I'm investigating servicestack.net - but it's examples and articles don't seem to cover authentication - is this something handled by servicestack.net - and if so how? In particular I'm interested in implementing support for: OAuth (So being able to inspect the raw request and validate it/retrieve the associated user info and associate with the request prior to passing it onto servicestack.net for processing). Session/cookie based authentication (so allowing for Ajax clients which already have a valid ASP.Net session to use that for authentication, instead of needing to explicitly pass login

Is this a good use-case for Redis on a ServiceStack REST API?

人盡茶涼 提交于 2019-12-02 14:58:40
I'm creating a mobile app and it requires a API service backend to get/put information for each user. I'll be developing the web service on ServiceStack , but was wondering about the storage. I love the idea of a fast in-memory caching system like Redis , but I have a few questions: I created a sample schema of what my data store should look like. Does this seems like it's a good case for using Redis as opposed to a MySQL DB or something like that? schema http://www.miles3.com/uploads/redis.png How difficult is the setup for persisting the Redis store to disk or is it kind of built-in when you

Best design pattern to control permissions on a “per object per user” basis with ServiceStack?

a 夏天 提交于 2019-12-02 14:56:24
I know that ServiceStack provides a RequiredRole attribute to control permissions, however, this does not fully work for my use case. I have a website with a lot of user-generated content. Users can only edit documents they have explicit permissions to. Permissions are controlled per object or group of the object. So, if a user is an admin of a group then they can edit all documents managed by that group. What is the best design pattern to control access to a request on a per object per user basis? I want to approach this with as DRY a methodology as possible as it will affect 95% of all my