如何解决完成 Source[ByteString, _] 时如何覆盖响应状态代码?
给定如下路线:
get {
complete(HttpEntity(ContentTypes.`application/json`,source))
//say source is Source[ByteString,_] from the Http response of a third party API
}
如何将来自 3rd 方 API 的响应状态代码映射(覆盖)到上述完整代码中。我知道使用 complete(Future(HttpResponse))
可以做到这一点,但我们如何使用源来实现这一点?
有没有办法使用 mapResponse 或 mapResponseEntity 来实现这一点?
解决方法
使用包含代码和实体的 using System;
using Raylib_cs;
using System.Numerics;
namespace Triangle
{
class Program
{
static void Main(string[] args)
{
Raylib.InitWindow(800,480,"Hello World");
Camera3D camera;
camera.position = new Vector3(10.0f,10.0f,10.0f); // Camera3D position
camera.target = new Vector3(0.0f,0.0f,0.0f); // Camera3D looking at point
camera.up = new Vector3(0.0f,1.0f,0.0f); // Camera3D up vector (rotation towards target)
camera.fovy = 120.0f; // Camera3D field-of-view Y
camera.type = CameraType.CAMERA_PERSPECTIVE; // Camera3D mode type
Vector3 point1 = new Vector3(0.0f,0.0f);
Vector3 point2 = new Vector3(10.0f,0.0f);
Vector3 point3 = new Vector3(10.0f,0.0f);
Raylib.SetCameraMode(camera,CameraMode.CAMERA_FREE); // Set a free camera mode
Raylib.SetTargetFPS(60);
Rlgl.rlDisableBackfaceCulling();
while (!Raylib.WindowShouldClose())
{
Raylib.UpdateCamera(ref camera);
Raylib.BeginDrawing();
Raylib.ClearBackground(Color.RAYWHITE);
Raylib.BeginMode3D(camera);
Raylib.DrawTriangle3D(point1,point2,point3,Color.BLACK);
Raylib.EndMode3D();
//text
Raylib.DrawRectangle(10,10,320,133,Raylib.ColorAlpha(Color.SKYBLUE,0.5f));
Raylib.DrawRectangleLines(10,Color.BLUE);
Raylib.DrawText("Free camera default controls:",20,Color.BLACK);
Raylib.DrawText("- Mouse Wheel to Zoom in-out",40,Color.DARKGRAY);
Raylib.DrawText("- Mouse Wheel Pressed to Pan",60,Color.DARKGRAY);
Raylib.DrawText("- Alt + Mouse Wheel Pressed to Rotate",80,Color.DARKGRAY);
Raylib.DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom",100,Color.DARKGRAY);
Raylib.EndDrawing();
}
Raylib.CloseWindow();
}
}
}
重载:
complete
或者自己构建整个响应并将其交给complete(
StatusCodes.BlockedByParentalControls,HttpEntity(ContentTypes.`text/plain(UTF-8)`,source))
:
complete
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。