提交 cb254cf8 编写于 作者: 若汝棋茗

修改Router的说明

上级 8412578b
......@@ -13,39 +13,33 @@ namespace WebApiServerApp
{
private static void Main(string[] args)
{
RpcStore rpcStore = new RpcStore(new TouchSocket.Core.Dependency.Container());
rpcStore.AddRpcParser("webApiParser", CreateWebApiParser());
rpcStore.RegisterServer<Server>();//注册服务
HttpService service = new HttpService();
service.Setup(new TouchSocketConfig()
.UsePlugin()
.SetListenIPHosts(new IPHost[] { new IPHost(7789) })
.ConfigureRpcStore(a =>
{
a.RegisterServer<Server>();//注册服务
}))
.Start();
var webApiParser = service.AddPlugin<WebApiParserPlugin>();
Console.WriteLine("以下连接用于测试webApi");
Console.WriteLine($"使用:http://127.0.0.1:7789/Server/Sum?a=10&b=20");
RpcStore.ProxyAttributeMap.TryAdd("webapi", typeof(WebApiAttribute));
//RpcStore.ProxyAttributeMap.TryAdd("webapi", typeof(WebApiAttribute));
//生成的WebApi的本地代理文件。
//ServerCellCode[] cellCodes = rpcStore.GetProxyInfo(RpcStore.ProxyAttributeMap.Values.ToArray());
//当想导出全部时,RpcStore.ProxyAttributeMap.Values.ToArray()
//string codeString = CodeGenerator.ConvertToCode("RRQMProxy", cellCodes);
rpcStore.ShareProxy(new IPHost(8848));//分享远程代理
Console.ReadKey();
}
private static IRpcParser CreateWebApiParser()
{
HttpService service = new HttpService();
service.Setup(new TouchSocketConfig()
.UsePlugin()
.SetListenIPHosts(new IPHost[] { new IPHost(7789) }))
.Start();
return service.AddPlugin<WebApiParserPlugin>();
}
}
public class Server : RpcServer
{
[Router(,)]
[WebApi(HttpMethodType.GET)]
public int Sum(int a, int b)
{
......
......@@ -21,9 +21,8 @@ namespace TouchSocket.Rpc.WebApi
{
/// <summary>
/// 表示WebApi路由。
/// 该模板在用于方法时,会覆盖类的使用。
/// <para>模板必须由“/”开始,如果没有设置,会自动补齐。</para>
/// <para>模板不支持参数约定,仅支持方法路由。</para>
/// 该模板在用于方法时,会覆盖类的使用。模板必须由“/”开始,如果没有设置,会自动补齐。
/// 模板不支持参数约定,仅支持方法路由。
/// <para>模板有以下约定:
/// <list type="number">
/// <item>不区分大小写</item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册