小编Ber*_*ian的帖子

从 bash 脚本发送 POST 请求

我想bash在发出POST请求后执行一个脚本。到目前为止,我正在使用它Postman来发送请求,但我想知道是否可以从bash脚本以及将json文件作为参数以某种方式执行此操作。

curl到目前为止,我已经研究过,但它不起作用:

bash文件

curl -X POST -d req.json http://localhost:9500
Run Code Online (Sandbox Code Playgroud)

JSON 文件 ( req.json)

{
    "id":5,
    "name":"Dan",
    "age":33,
    "cnp":33,
    "children":100,
    "isMarried":0
}
Run Code Online (Sandbox Code Playgroud)

我只是收到错误:

HTTP/1.0 503 Service Unavailable
Run Code Online (Sandbox Code Playgroud)

与尾随 HTML

bash json http-post

14
推荐指数
1
解决办法
3万
查看次数

被 CORS 策略阻止的 Blazor 请求

我正在尝试从Blazor(客户端)客户端向服务器发送请求,但我不断收到此错误:

从源 '[origin route]' 获取在 '[route]'(重定向自 '[other route]')的访问已被 CORS 策略阻止:请求中不存在 'Access-Control-Allow-Origin' 标头资源。如果不透明响应满足您的需求,请将请求的模式设置为“no-cors”以在禁用 CORS 的情况下获取资源。

在服务器上,我已经CORS在管道中添加了扩展,但无济于事:

服务器启动

public void ConfigureServices(IServiceCollection services) {
            services.AddCors();
            services.AddResponseCompression(options => {
                options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
                {
                    MediaTypeNames.Application.Octet,
                    WasmMediaTypeNames.Application.Wasm,
                });
            });
}
 public void Configure(IApplicationBuilder app, IHostingEnvironment env) {

            app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials());

            app.UseResponseCompression();

            app.UseMvc();

            app.UseBlazor<Client.Startup>();

        }
Run Code Online (Sandbox Code Playgroud)

Blazor 客户端请求

public async Task<Catalog> GetCatalogAsync() {
            try {
                HttpRequestMessage message = new HttpRequestMessage {
                    RequestUri = new Uri(BASE_PATH + Routes.GET_CATALOG), //BASE_PATH= 172.XX.XX.XX:8600
                    Method = HttpMethod.Get
                };
                var …
Run Code Online (Sandbox Code Playgroud)

cors .net-core blazor

10
推荐指数
1
解决办法
1万
查看次数

为什么参数化类型实例无需指定类型参数即可工作

具有参数化类型时: data A a=X a| Y

我已经尝试(成功)实现Functor并且Applicative未指定type参数:

instance Functor A where代替instance Functor (A a) where
为什么行得通?

LYAH中,似乎所有示例都在其所有参数中指定了type参数typeclass instances。什么时候应该忽略type参数?

haskell typeclass type-parameter

9
推荐指数
2
解决办法
110
查看次数

使用无点表示法时如何强制执行类型

您好如何在编写方法时强制执行GHC 类似函数Data.Text.read=~运算符的类型Text.Regex.Posix

例:
a=["1.22","3.33","5.55"]

没有点免费:
b= map (\x-> read x ::Double) a

如何read使用无点表示法强制执行类型?

b=map read::Double a
b= map (read . f1 .f2 .f3... . fn )::Double a (构成方法时)
,其中f1 , f2 ...fn一些方法

或者更好的是,read当它属于一系列方法时,如何指定类型,不是在链的末尾!:
b=map (f2 . read . f1 ) a

haskell pointfree

8
推荐指数
1
解决办法
114
查看次数

Dotnet Restore在Docker构建中失败

您好,我正在尝试dockerize一个ASP NET Core 2.1应用程序,docker build当它执行时失败dotnet restore。我已经检查了其他线程来解决此特定问题,
Nuget连接尝试失败“无法加载源的服务索引”

那里提供的解决方案对我没有帮助。

Docker文件

ARG serverPath=./Core/Server

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app


COPY ./Core/Server/*.csproj ./
RUN dotnet restore  //fails here

COPY ./Core/Server/ ./
RUN dotnet publish -c Release -o out  


FROM microsoft/dotnet:2.1-aspnetcore-runtime 
WORKDIR /app
COPY --from=build-env /app/out  .
ENTRYPOINT ["dotnet","Server.dll"]
Run Code Online (Sandbox Code Playgroud)

docker build的输出

$ docker build -t server .
Sending build context to Docker daemon  11.13MB
Step 1/11 : ARG serverPath=./Core/Server
Step 2/11 : FROM microsoft/dotnet:sdk AS …
Run Code Online (Sandbox Code Playgroud)

nuget docker dotnet-restore

8
推荐指数
1
解决办法
1069
查看次数

如何使用 blazor 绑定时间类型的输入

你好,我有2类型的变量int,我想绑定到minmax的值input类型time
我怎样才能做到这一点?由于有 2 个不同的变量,

我不知道该在该bind字段中放置什么。还有minmax属性。

<input type="time" min="@model.min" max="@model.max" bind=?/>

我应该在里面放什么bind

更新 在更彻底的分析中,我决定我需要 2 个类型的变量,Timespan并将它们绑定到 2 个类型的输入time

binding input blazor

7
推荐指数
3
解决办法
4054
查看次数

可以部分使用函子吗

我正在尝试实现fmap以下类型:

data Tree a = Leaf a | Node a (Tree a) (Tree a) | Empty deriving (Eq,Show)
Run Code Online (Sandbox Code Playgroud)
instance Functor Tree where
        fmap _ Empty=Empty
        fmap f (Leaf x)=Leaf (f x)
        fmap f (Node t left right)=Node (f t) left right
Run Code Online (Sandbox Code Playgroud)

我不断收到类型不匹配错误:

错误

* Couldn't match type `a' with `b'
      `a' is a rigid type variable bound by
        the type signature for:
          fmap :: forall a b. (a -> b) -> Tree a -> Tree b
        at Monad.hs:8:9-12 …
Run Code Online (Sandbox Code Playgroud)

haskell types functor

6
推荐指数
1
解决办法
79
查看次数

使用 .NET Core 3.0 添加 swagger 时出现异常

我正在尝试将 swagger 集成到一个ASP NET Core 3.0项目中,它在ConfigureServices方法中抛出异常:

我正在使用Swashbuckle.AspNetCore4.0.1。

我也检查了这个问题,还有这个

public void ConfigureServices(IServiceCollection services)
        {


            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
                {
                    Version = "v1",
                    Title = " API",
                    Description="API for the  Server",
                });

            });
        }
Run Code Online (Sandbox Code Playgroud)

例外

System.AggregateException
  HResult=0x80131500
  Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': Failed to compare two elements in the array.) (Error while validating the service descriptor …
Run Code Online (Sandbox Code Playgroud)

swagger swashbuckle asp.net-core-3.0

6
推荐指数
2
解决办法
1万
查看次数

为什么.cshtml更改后刷新后页面不更新

我正在尝试Blazor,我不明白为什么component在刷新浏览器页面后更改a时,它不会更新?client更新本身不应该与更新类似angular吗?

仅在重新启动blazor服务器时刷新。

Index.cshtml

@page "/"

<h1>Hello, world!</h1>
Run Code Online (Sandbox Code Playgroud)

如果更改,可以说<h1>to 内的文本Hello people,则保存项目并刷新页面(如本Blazor教程中所建议),我不应该看到Hello people吗?

client-side asp.net-core blazor

5
推荐指数
3
解决办法
2427
查看次数

如何在Blazor中启用/禁用输入

我正在尝试基于Blazor在Blazor中进行Enable/Disable一组time输入checkbox;对于inputs类型button,以下解决方案有效,对于类型的输入time则无效:

有效的按钮输入解决方案

<button type="button"
    class="@this.SetButton">
</button>

[Parameter] public bool state{get;set;} 
public string SetButton() {
       string result = state == true ? "" : "disabled";
       return result;
}
Run Code Online (Sandbox Code Playgroud)

尝试输入无效的时间

<input bind="@IsDisabled" type="checkbox" />

<input class="@this.GetGroupState()"  type="time" />


 protected bool IsDisabled { get; set; }
 public string GetGroupState() {
            return this.IsDisabled ? "disabled" : "";
        }
Run Code Online (Sandbox Code Playgroud)

PS在第一种情况下,bool它是另一个参数,component所以我不绑定它。但在第二种情况下,它必然会checkbox

html disabled-input blazor

5
推荐指数
4
解决办法
2616
查看次数