配置 ServiceStack 基本 URI [英] Configure ServiceStack Base URI

查看:30
本文介绍了配置 ServiceStack 基本 URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用服务堆栈创建一个自托管的 REST 服务 &AppHostHttpListenerBase.我想为我的服务使用基本 URI(例如api"),如下所示:

I'm creating a self-hosted REST service using service stack & AppHostHttpListenerBase. I'd like to use a base URI for my services (e.g. "api") like so:

http://myserver/api/service1/param
http://myserver/api/service2/param

如果不在我的每条路线中定义api",我该如何做到这一点.在IIS中,我可以设置一个虚拟目录来隔离服务,但是在自托管时如何做到这一点?

How do I do this without defining "api" in each of my routes. In IIS, I can set a virtual directory to isolate the services, but how do I do this when self-hosting?

推荐答案

ServiceStack 的 HttpListener 主机 期望托管在根/路径上,因为正常用例是让每个自托管服务在不同的自定义端口上可用.

ServiceStack's HttpListener hosts expects to be hosted a the root / path as the normal use-case is to have each self-hosted service available on different custom ports.

由于它当前不支持在/custompath 上托管,因此您必须在所有服务路由上指定 /api/ 前缀.

Since it doesn't currently support hosting at a /custompath, you would have to specify /api/ prefix on all your service routes.

如果需要,请添加问题查看对在自定义路径上托管的支持.

Add an issue if you want to see support for hosting at custom paths.

这篇关于配置 ServiceStack 基本 URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆