当我从浏览器执行以下代码时,服务器给我400并抱怨请求体丢失.任何人都知道如何传递一个简单的字符串并让它作为请求体发送?
let content = 'Hello world'
axios.put(url, content).then(response => {
resolve(response.data.content)
}, response => {
this.handleEditError(response)
})
Run Code Online (Sandbox Code Playgroud)
如果我在[]中包含内容,它就会通过.但随后服务器将其作为以[并以]结尾的字符串接收.这似乎很奇怪.
摆弄后,我发现以下作品
let req = {
url,
method: 'PUT',
data: content
}
axios(req).then(response => {
resolve(response.data.content)
}, response => {
this.handleEditError(response)
})
Run Code Online (Sandbox Code Playgroud)
但是,第一个不应该工作吗?
我正在尝试传递下面格式的字符串作为http post请求的正文.
param1=PARAM1¶m2=PARAM2¶m3=PARAM3
Run Code Online (Sandbox Code Playgroud)
但改装编码我的身体,以便=成为\ u003d和&成为\ u0026.我最终得到一个字符串,实际上看起来像这样:
param1\u003dPARAM1\u0026param2\u003dPARAM2\u0026param3\u003dPARAM3
Run Code Online (Sandbox Code Playgroud)
我怎么能防止这种情况?
我的改造休息api定义如下.
public interface RestAPI {
@POST("/oauth/token")
public void getAccessToken(@Body String requestBody, Callback<Response> response);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 helmfile 部署图表。使用相同版本和相同集群在本地运行得很好。
头盔文件
environments:
dev:
values:
- kubeContext: nuc
- host: urbantz-api.dev.fitfit.dk
prod:
values:
- kubeContext: nuc
- host: urbantz-api.fitfit.dk
releases:
- name: urbantz-api
namespace: urbantz-api-{{ .Environment.Name }}
chart: helm/
kubeContext: "{{ .Values.kubeContext }}"
# verify: true
values:
- image:
tag: '{{ requiredEnv "IMAGE_TAG" }}'
- ingress:
enabled: true
hosts:
- host: {{ .Values.host }}
paths:
- path: /
Run Code Online (Sandbox Code Playgroud)
完整的管道可以在这里找到,但相关命令可以在下面看到
[ "$IMAGE_TAG" == "latest" ] && ./helmfile --debug -e dev sync
Run Code Online (Sandbox Code Playgroud)
管道的完整输出可以在这里找到,但相关部分可以在下面看到
...
NOTES:
1. Get …Run Code Online (Sandbox Code Playgroud) 我正在尝试调用可重用的工作流程。
https://github.com/dhis2-sre/gha-workflows/blob/master/.github/workflows/instance-manager.yaml
调用者如下所示
name: Tests, build and deploy
on:
push:
branches:
- master
- feature/**
tags:
- v*.*.*
pull_request:
workflow_dispatch:
jobs:
call-workflow:
uses: dhis2-sre/gha-workflows/.github/workflows/instance-manager.yaml@v0.2.0
with:
DOCKER_IMAGE_NAME: dhis2/instance-manager-api
PROCESS_NAME: dhis2-instance-manager
DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
SOPS_KMS_ARN: "${{ secrets.SOPS_KMS_ARN }}"
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
KUBECONFIG: "${{ secrets.KUBECONFIG }}"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Invalid workflow file
The workflow is not valid. .github/workflows/cicd.yaml (Line: 21, Col: 24): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DOCKER_USERNAME .github/workflows/cicd.yaml (Line: 22, …Run Code Online (Sandbox Code Playgroud) 我已将我的图表发布到图表博物馆。是的,我已经运行了“helm repo update”。
$ helm search chartmuseum/
NAME CHART VERSION APP VERSION DESCRIPTION
chartmuseum/whoami 1-master A Helm chart for whoami
chartmuseum/whoami-master 0.0.1-SNAPSHOT A Helm chart for whoami
chartmuseum/whoami-release 0.0.1-SNAPSHOT A Helm chart for whoami
Run Code Online (Sandbox Code Playgroud)
但是当我试图找到它时......
$ helm install chartmuseum/whoami-release
Error: failed to download "chartmuseum/whoami-release" (hint: running `helm repo update` may help)
Run Code Online (Sandbox Code Playgroud)
有人知道我做错了什么吗?
我将我的 Retrofit 代码包装在如下所示的类中。如果从我发布的代码中不清楚,它正在与带有 OAuth 的宁静服务进行交互。
这对于线程安全是否可行?我的意思是说用户一次点击两个地方并触发两个 API 调用。这段代码好用吗?我需要保持内部队列吗?如果是这样,我应该怎么做?
从这个答案来看,我会说,不。但我不确定。
public class RestClient implements IRestClient {
private IRestAPI api;
/**
*
* @param accessToken
*/
public RestClient(final String accessToken)
{
RequestInterceptor requestInterceptor = new RequestInterceptor()
{
@Override
public void intercept(RequestFacade request) {
request.addHeader("Authorization", "Bearer " + accessToken);
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(Config.ENDPOINT)
.setRequestInterceptor(requestInterceptor)
.build();
api = restAdapter.create(IRestAPI.class);
}
@Override
public void getUserProfile(Callback callback) {
api.getUserProfile(callback);
}
@Override
public void getFriendList(Callback callback) {
api.getFriendList(callback);
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我知道这是一个常见问题,但我无法通过阅读之前提出的问题找到解决方案.
我实际上得到了两个错误,但第一个是关于角度无法找到我的控制器.
http://errors.angularjs.org/1.4.2/ $ injector/nomod?p0 = myApp.controllers
我的目录结构如下所示:
.
??? static
??? index.html
??? js
? ??? app.js
? ??? controllers.js
??? lib
? ??? angular-ui-router.min.js
??? partials
??? view1.html
??? view2.html
Run Code Online (Sandbox Code Playgroud)
我的索引文件如下所示:
<html ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Hello AngularJS</title>
</head>
<body>
<div ui-view></div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular-route.min.js"></script>
<script type="text/javascript" src="lib/angular-ui-router.min.js"></script>
<script type="text/javascript" src="js/controllers.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的app.js文件如下所示:
(function(angular) {
var app = angular.module('myApp', ['ui.router', 'myApp.controllers']);
app.config(function($stateProvider) {
$stateProvider.state('view1', {
url: '/view1',
templateUrl: 'partials/view1.html',
controller: 'View1Controller' …Run Code Online (Sandbox Code Playgroud) 我似乎无法使我的安全配置正确.无论我在使用hasRole端点时做什么,总是返回403.
此外,除非我重复我的,我不能得到任何工作antMatchers下都.requestMatchers()和.authorizeRequests().我在这里显然遗漏了一些东西.
基本上我希望一切都要求身份验证,但只有一些端点只有在用户是某些组的成员时才可访问(现在只是管理员).
我的安全配置如下.除了hasRole工作之外的一切.
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.requestMatchers()
.antMatchers(HttpMethod.GET, "/v2/api-docs", "/swagger-resources/**", "/swagger-ui.html")
.antMatchers(HttpMethod.GET, "/users")
.and()
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/v2/api-docs", "/swagger-resources/**", "/swagger-ui.html").permitAll()
.antMatchers(HttpMethod.GET, "/users").hasRole("ADMIN")
.anyRequest().authenticated();
}
// Inspiration: https://spring.io/blog/2015/06/08/cors-support-in-spring-framework#comment-2416096114
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**");
}
}
Run Code Online (Sandbox Code Playgroud)
我的AuthenticationConfiguration如下
@Configuration
@EnableResourceServer
public class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
private final …Run Code Online (Sandbox Code Playgroud) 正如标题所示,我正在尝试使用 helmfile 和通过值的数据源来设置 grafana。
我可以在这里找到文档,但遗憾的是我的知识太有限,无法使其发挥作用。
我的 helmfile 的相关部分在这里
releases:
...
- name: grafana
namespace: grafana
chart: stable/grafana
values:
- datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local
Run Code Online (Sandbox Code Playgroud)
我偶然发现了这一点,似乎我也可以通过环境变量来做到这一点,但我似乎找不到一种简单的方法来在我的 helmfile 中设置此类变量。
如果有人对 helmfile、json 等有更好的了解,可以向我展示或引导我走向正确的方向,我将不胜感激。
更新:感谢@WindyFields,我的最终解决方案如下
releases:
...
- name: grafana
namespace: grafana
chart: stable/grafana
values:
- datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus-server.prometheus.svc.cluster.local
isDefault: true
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 kubectl 等待服务获取分配的外部 IP。我一直在尝试使用下面的内容来开始
kubectl wait --for='jsonpath={.spec.externalTrafficPolicy==Cluster}' --timeout=30s --namespace cloud-endpoints svc/esp-echo
Run Code Online (Sandbox Code Playgroud)
但我不断收到以下错误消息
error: unrecognized condition: "jsonpath={.spec.externalTrafficPolicy==Cluster}"
Run Code Online (Sandbox Code Playgroud)