我正在制作一个API(带go),我正在开发会话部分.在研究了什么用于会话后,我发现JWT真的很有趣.
但是我不太确定在一些教程之后理解如何使用它.所以这是我的想法:
func main() {
router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/login", login)
router.HandleFunc("/logout", logout)
router.HandleFunc("/register", register)
http.ListenAndServe(":8080", router)
}
Run Code Online (Sandbox Code Playgroud)
处理完这些请求后,我创建了不同的函数.
func login(w http.ResponseWriter, r *http.Request) {
/*
Here I just have to search in my database (SQL, I know how to do it). If the user is registered, I create a token and give it to him, but how can I do it?
*/
}
func logout(w http.ResponseWriter, r *http.Request) {
/*
I get a token and stop/delete it?
*/
}
func …Run Code Online (Sandbox Code Playgroud) 我搜索但是我无法找到是否可以从我的便携式代码中更改每个平台的StatusBar颜色?(用于Android, iOS & WinPhone 8.1)
public App()
{
// Change the StatusBar color
MainPage = new MainPageUser();
}
Run Code Online (Sandbox Code Playgroud) 我正在使用AbsoluteLayout的Xamarin.Forms,但是,我不确定如何处理元素的位置.
我正在使用比例值,所以如果我AbsoluteLayout.LayoutBounds="1, 0.05, 0.15, 0.1"在每个值都是比例的位置放置一个元素(所以标志是"全部" AbsoluteLayout.LayoutFlags="All")
它将放置在屏幕的顶部/右侧.然而,它不会占据一席之地.那意味着什么呢?如果外面的每个元素都重新定位到屏幕上?
但是现在,当你放置一个元素时,另一个问题是基于X/Y位置?是中心还是其他方面?
在这个例子中,我尝试使用0.15,但渲染有点奇怪,所以我把0然后渲染匹配我想要的.
你可以说"测试它,你会看到."然而,对于设计师和我来说,定位每个元素是浪费时间,因为我们不确定它是如何工作的.因此,我们努力尝试使用debuging ..
我们还在搜索是否存在一个软件来生成有关设计师设计的位置.我们指的是元素的位置X/Y百分比.
预先感谢 !
对于"代码呈现会话",我想将我的Jupyter NoteBook转换为幻灯片.它实际上非常好,但对于Dataframe显示.
我目前在笔记本上有这个显示:
我在幻灯片上得到了:
为什么?是否可以在笔记本/幻灯片上获得相同的渲染?
谢谢
我是Go的新手,然后我搜索了很多如何使用静态函数/变量(例如C#)的静态类.但是,我找不到任何有关它的答案.也许这个问题看起来很愚蠢,但是当我不确定或者什么时候我完全不理解时,我也不喜欢这个问题.
假设我们有这个代码:
public class Program
{
public static string name = "Program tester.";
public enum Importance
{
None,
Trivial,
Regular,
Important,
Critical
};
public static void tester(Importance value)
{
// ... Test against known Importance values.
if (value == Importance.Trivial)
{
Console.WriteLine("Not true");
}
else if (value == Importance.Critical)
{
Console.WriteLine("True");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我理解Golang是一个类似C的,那么它是否有一些像上面这样的行为,比如C++/C#语言?我上面的代码可以用C++/C#来实现,或者它的方法是通过C语言传递(使用C模块化编程方式)?
初始问题来自关于Xamarin.Forms.Map的折线的个人项目,其中初始化是通过XAML部件的绑定实现的.
让我通过一个例子来说明一点:
我有一个 继承自的CustomMap.cs对象Xamarin.Forms.Map (此文件位于PCL部分 - > CustomControl/CustomMap.cs)
public class CustomMap : Map, INotifyPropertyChanged
{
public static readonly BindableProperty PolylineAddressPointsProperty =
BindableProperty.Create(nameof(PolylineAddressPoints), typeof(List<string>), typeof(CustomMap), null);
public List<string> PolylineAddressPoints
{
get { return (List<string>)GetValue(PolylineAddressPointsProperty); }
set
{
SetValue(PolylineAddressPointsProperty, value);
this.GeneratePolylineCoordinatesInner();
}
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我有一个可评估的可绑定属性,而XAML似乎没有使用此评估器.
因此,调用控件的页面的MainPge.xaml部分如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:control="clr-namespace:MapPolylineProject.CustomControl;assembly=MapPolylineProject"
x:Class="MapPolylineProject.Page.MainPage">
<ContentPage.Content>
<control:CustomMap x:Name="MapTest" PolylineAddressPoints="{Binding AddressPointList}"
VerticalOptions="Fill" HorizontalOptions="Fill"/>
</ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
该MainPge.xaml.cs部分:
public partial …Run Code Online (Sandbox Code Playgroud) 我试图从我拥有的每个组件页面访问我的商店,所以我按照以下教程连接 React Router 和 MobX。
http://frontendinsights.com/connect-mobx-react-router/
但是,我在MobX 方式中遇到了一个问题——提供者组件。
这是代码示例:
import { Provider } from 'mobx-react';
import usersStore from './stores/usersStore';
import itemsStore from './stores/itemsStore';
const stores = { usersStore, itemsStore };
ReactDOM.render(
<Provider {...stores}>
<Router history={history}>
<Route path="/" component={App}>
</Route>
</Router>
</Provider>,
document.getElementById('app')
);
Run Code Online (Sandbox Code Playgroud)
我试图在 index.js
import React from 'react'
import { render } from 'react-dom'
import { Router, hashHistory, Route, IndexRedirect } from 'react-router'
import App from './webapp/App'
import Home from './components/pages/Home'
import Dogs from './components/pages/Dogs' …Run Code Online (Sandbox Code Playgroud) 我目前正在阅读很多关于微服务的内容,但我仍然不了解某些部分.我做了以下抽奖:
每个微服务有2个访问:
如果我想登录,我可以发送一个Http请求到我的身份验证服务.但是,如果我想访问需要您已连接的Stuff服务呢?
假设用户想要显示数据库STUFF中可用的东西,服务Stuff将首先检查连接用户的"令牌"是否正确,通过与Authentication服务交换,然后返回东西或"登录"要求".
所以我不明白的是,如果需要连接客户端的每个服务需要与身份验证交换,那么它将创建一个巨大的互联网流量,以便检查每个用户请求..所以我虽然做一个身份验证服务每个服务,但由于我应该只有一个数据库,那么数据库会减慢流量吗?
另外,如果我理解,每个微服务应该在不同的服务器上,而不是同一个服务器上?
我希望我很清楚,不要犹豫,要求更多细节!
提前致谢 :)
马克斯
根据@ notionquest的回答:
所以它看起来应该更合适吗?
此外,根据Peter的评论,每个服务都可以实现自己的中间件(如上所述的JWT),因此API网关只是一个"传递".但是,我觉得这对我来说不是很好,因为每个服务都会对每个内部交换进行一次令牌检查,不是吗?
对于这些东西,它很容易,因为它只检查一次令牌.现在,让我们说,在用户拿到东西后,他选择一个并想购买它.然后"购买服务"将调用服务服务,以验证项目的价格,但是...它将必须检查用户令牌,因为这些东西是"经过身份验证的访问",因此这意味着"购买" "服务和"东西"服务都检查令牌,这增加了额外的检查.
我虽然关于服务之间的内部保证访问但是它值得吗?
此外,也许你说为每个服务实现中间件,因为他们有REST访问权限,但API网关只会破坏拥有REST访问权限的想法
到目前为止,我一直关注这篇文章,它对我有很大帮助,但是,我现在得到了“ invalid_grant”。以下内容:https : //developer.apple.com/documentation/signinwithapplerestapi/errorresponse我了解由于授权授予或刷新令牌无效,我遇到了问题。
尽管进行了搜索和尝试(和重试),但我仍然受困,并且我不知道它来自何处。我使用了https://developer.apple.com/documentation/authenticationservices/adding_the_sign_in_with_apple_flow_to_your_app提供的应用程序
现在,我从上面的应用程序中获取了令牌,我尝试从C#后端对其进行验证,但得到400响应代码invalid_grant。
我可以从帖子中注意到的唯一区别是,与下图相比,我没有任何[Verify]按钮(选项)或[Download]门户中的按钮。我不知道这是否相关,但我正在尝试提供尽可能多的详细信息:
希望有人可以提供帮助,谢谢您的帮助:)如有需要,随时询问更多详细信息
最高
我正在尝试按照文档https://devcenter.heroku.com/articles/heroku-cli#download-and-install在我的 Mac 上安装 Heroku,但在运行安装 heroku 的命令时遇到问题:
MBP-de-Emixam23:~ emixam23$ brew install heroku
Updating Homebrew...
==> Installing heroku from heroku/brew
==> Downloading https://cli-assets.heroku.com/homebrew/node-12.16.2.tar.xz
Already downloaded: /Users/emixam23/Library/Caches/Homebrew/downloads/5787f9331a645901d1511ff2973c961e1037248779c2b5628ec2601273fb979b--node-12.16.2.tar.xz
==> Downloading https://cli-assets.heroku.com/heroku-v7.42.4/heroku-v7.42.4.tar.
Already downloaded: /Users/emixam23/Library/Caches/Homebrew/downloads/15cbf813f5f04cde9c65e953825e9514cfe5f571108d68a5284521d8592bcf4f--heroku-v7.42.4.tar.xz
==> Installing dependencies for heroku/brew/heroku: heroku/brew/heroku-node
==> Installing heroku/brew/heroku dependency: heroku/brew/heroku-node
Error: An exception occurred within a child process:
ArgumentError: user emixam23 doesn't exist
Run Code Online (Sandbox Code Playgroud)
任何的想法?:o
谢谢你的帮助