REST API 介绍

IntelliJ IDEA的这个接口调试工具真是太好用了! - 你有一个思想,我有一个思想,我们交换后,一个人就有两个思想 - If you can NOT explain it simply, you do NOT understand it well enough 现陆续将Demo代码和技术文章整理在一起 Github实践精选,方便大家阅读查看,觉得不错,还请Star???? 抗击疫情,在家办公。工作照常干,领导需要几个新功能接口开发。以前在... 阅读详情

REST API 教程

 

REST(Representational State Transfer)是一种软件架构风格,用于设计网络应用程序的接口。

REST API(Application Programming Interface)是基于 REST 原则构建的 Web 服务接口,它允许不同的系统通过 HTTP 协议进行通信和数据交换。

REST API 的核心特点包括:

  • 无状态性(Stateless):每个请求都包含处理该请求所需的全部信息
  • 资源导向(Resource-based):所有数据被视为资源,通过 URI 标识
  • 统一接口(Uniform Interface):使用标准 HTTP 方法(GET、POST、PUT、DELETE 等)
  • 可缓存性(Cacheable):响应可以明确标记为可缓存或不可缓存

REST API 的核心概念

1. 资源(Resource)

在 REST 中,资源是任何可以命名的信息,如用户、产品、订单等。每个资源都有一个唯一的标识符(URI)。

2. HTTP 方法

REST API 使用标准 HTTP 方法来定义对资源的操作:

HTTP 方法 描述 幂等性 安全性
GET 获取资源 是 是
POST 创建新资源 否 否
PUT 更新整个资源 是 否
PATCH 部分更新资源 否 否
DELETE 删除资源 是 否

3. 状态码

HTTP 状态码表示请求的处理结果:

状态码 类别 常见状态码
2xx 成功 200 OK, 201 Created
3xx 重定向 301 Moved Permanently
4xx 客户端错误 400 Bad Request, 404 Not Found
5xx 服务器错误 500 Internal Server Error

4. 数据格式

REST API 常用的数据交换格式:

  • JSON(JavaScript Object Notation)
  • XML(eXtensible Markup Language)
  • 有时也使用 YAML、CSV 等格式

REST API 设计最佳实践

1. URI 设计原则

  • 使用名词而非动词表示资源
    • 好:/users
    • 不好:/getUsers
  • 使用小写字母和连字符(-)
  • 避免文件扩展名
  • 使用复数形式表示集合
  • 分层次表示关系:/users/{id}/orders

2. 版本控制

建议在 URI 或请求头中包含 API 版本信息:

  • URI 路径:/v1/users
  • 请求头:Accept: application/vnd.myapi.v1+json

3. 过滤、排序和分页

对于集合资源,提供查询参数:

  • 过滤:/users?role=admin
  • 排序:/users?sort=-created_at
  • 分页:/users?page=2&limit=10

4. 安全性

  • 使用 HTTPS
  • 实施身份验证(OAuth2、JWT)
  • 限制请求频率
  • 验证输入数据

REST API 示例

用户管理 API 示例

实例

# 获取用户列表
GET /api/v1/users
Accept: application/json

# 创建新用户
POST /api/v1/users
Content-Type: application/json

{
  "name": "张三",
  "email": "zhangsan@example.com"
}

# 获取特定用户
GET /api/v1/users/123
Accept: application/json

# 更新用户信息
PUT /api/v1/users/123
Content-Type: application/json

{
  "name": "张三(更新)",
  "email":&nbs

【2025】camunda API接口介绍以及REST接口使用(3) 中心起点是 ProcessEngine,可以通过配置部分中描述的几种方式创建。从 ProcessEngine,您可以获取包含工作流/BPM 方法的各种服务。ProcessEngine 和服务对象是线程安全的。因此,您可以为整个服务器保留对其中一个的引用。ProcessEngines.getDefaultProcessEngine()将在第一次调用时初始化并构建流程引擎,之后始终返回相同的流程引擎。 阅读详情

相关推荐

kyuubi rest api介绍

全网都没有找到介绍怎么使用kyuubi rest api,于是自己研究了一下

terry21的专栏 2074

手把手教你用VM实现欧姆龙PLC数据采集(含Fins协议配置详解)

本文详细介绍了如何使用VM(VisionMaster)实现与欧姆龙PLC的数据采集,重点解析了Fins协议(包括Fins TCP/UDP)的配置步骤。从网络环境搭建、PLC的IP地址设置,到VM端Fins通讯通道的详细配置与数据点映射,提供了完整的实战指南。文章还涵盖了数据收发解析、常见问题排查清单,帮助工程师快速完成视觉系统与PLC的稳定集成。

weixin_29171087的博客 189

退火朗之万动力学采样

退火朗之万动力学采样(Simulated Annealing Langevin Dynamics Sampling)结合了退火技术和朗之万动力学,是一种用于分子模拟和统计物理中的计算方法。这种方法可以帮助系统从局部最小值中逃逸,以找到全局最小值或进行有效的配置空间探索。

weixin_39699362的博客 1949

GLMM(广义线性混合模型)原理以及分析步骤

广义线性混合模型(GLMM)是生态与进化研究中处理非正态数据的定制化工具,能同时分析固定效应和随机效应。它通过链接函数连接响应变量与预测因子,支持二项分布、泊松分布等非正态数据。研究流程包括:明确分析目标(固定效应影响与随机效应方差)、选择合适变量与分布、数据验证、参数估算(需根据模型复杂度选择PQL、拉普拉斯近似等方法)及模型优化(检验过离散与残差,通过信息准则或假设检验筛选最优模型)。GLMM能有效解决传统方法无法处理的"伪重复"和推广性问题,为复杂生物数据提供可靠分析框架。

wewil_lwin的博客 4989

用YOLO11-seg玩转裂缝分割:CBAM注意力魔改+轻量化GhostConv实战

本文详细解析了如何利用YOLO11-seg进行裂缝分割任务,结合CBAM注意力机制和GhostConv轻量化改造,显著提升模型性能。通过实战案例展示从数据准备、模型训练到部署优化的全流程,特别针对小目标检测和复杂背景干扰等挑战提供解决方案,最终实现高效准确的裂缝检测系统。

j0k1l2m3n的博客 287

告别盲目调参:手把手教你用RKISP2.x Tuner理解AWB、AE、NR等核心模块

本文详细介绍了如何使用RKISP2.x Tuner工具进行ISP调试,重点解析AWB、AE、NR等核心模块的调参技巧。通过RV1126平台的实际操作演示,帮助工程师快速掌握可视化对比实验方法,告别盲目调参,提升图像信号处理效率。

weixin_30300225的博客 392

中科蓝讯蓝牙耳机SDK实战:从目录解析到消息处理框架

本文深入解析中科蓝讯蓝牙耳机SDK的目录结构与消息处理框架,提供从硬件驱动到蓝牙功能定制的实战指南。重点剖析SDK核心模块如消息队列机制、按键事件处理及电量报告优化,并分享二次开发中的调试技巧与避坑经验,助力开发者高效完成TWS耳机功能定制。

weixin_30335575的博客 388

YOLO26改进 - 注意力机制 | MLLAttention (Mamba-Like Linear Attention) 类Mamba线性注意力:动态感受野适配多尺度目标

本文介绍了Mamba-Like Linear Attention (MLLA)模型及其在yolo26中的集成。MLLA结合了Mamba和线性注意力Transformer的优点,线性注意力降低计算复杂度,Mamba有效建模序列。该模型将Mamba的遗忘门和块设计等关键元素与线性注意力结合,还可用位置编码替代遗忘门。我们将MLLA引入yolo26,在检测头的不同尺度特征图上应用。实验表明,改进后的yolo26在目标检测任务中表现良好,体现了MLLA在提升模型性能上的有效性。

魔改工程师的博客 1150

SAP GR(Group Reporting)配置篇(五)

1.5、合并的货币换算1.5.1指定折算比率菜单路径组报表的SAP S4HANA >合并的货币换算>-指定折算汇率事务代码GCRF说 明1.5.2维护汇率菜单路径组报表的SAP S4HANA >合并的货币换算>维护汇率事务代码CXCC/OB08说 明实际测试的时候根据实际情况维护汇率。输入换算比率。1.5.3定义汇率标识符菜单路径组报表的SAP S4HANA >合并的货币换算>定义汇率标识符事务代码OC41说 明配置了月末汇率和平均汇率。

weixin_43853754的博客 554

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

上一篇: Python 日期和时间
下一篇: 【无标题】
奋进学堂
奋进学堂 新星创作者: 云计算技术领域 新星创作者: 云计算技术领域
博客等级 码龄8年 5183粉丝 906原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奋进学堂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值