可以在此处找到有关 express-jwt 模块的信息:
在我的main.js服务器文件中,我有以下内容:
import ExpressJwt from 'express-jwt';
// import other crap...
let token = ExpressJwt({
secret: 'whatever',
audience: 'whatever',
issuer: 'whatever'
});
app.all('/apiv1', token.unless({ path: ['apiv1/user/create', '/apiv1/auth/login']}));
app.use('/apiv1/user', user);
app.use('/apiv1/auth', auth);
Run Code Online (Sandbox Code Playgroud)
其中user和auth是处理我的路由中间件。我想要做的很明显;拒绝所有未经身份验证的用户访问 API,除非他们尝试apiv1/user/create通过apiv1/auth/login.
但是,每当我尝试向上述未受保护的路径发出请求时,都会收到错误消息:
UnauthorizedError:未找到授权令牌
它仍然保护我指定为不受保护的路线!我也试过:
app.use('/apiv1/user', token.unless({ path: ['/apiv1/user/create'] }), user);
app.use('/apiv1/auth', token.unless({ path: ['/apiv1/auth/login'] }), auth);
Run Code Online (Sandbox Code Playgroud)
但这没有用。我还尝试将正则表达式用于除非路径,但这也不起作用。
我是app.all('/apiv1', token...)通过这个答案得出的,但该解决方案并没有产生我想要的功能。
我需要一些关于在 Docker 容器中使用 MySQL 的帮助。我认为 Docker 的全部意义在于隔离沙箱中的进程并让它们像正常进程一样运行 - 我没有得到这个功能。
每当我运行从我自己的映像构建的 MySQL 容器时,它都会运行 2 秒钟,然后停止。尝试docker run -i -t <imageid>给了我这个:
root@CenturionX:/home/centurionx/Code/Git/gdms-rcon# docker run -i -t e2d
150221 05:25:21 mysqld_safe Logging to '/var/lib/mysql/28123b6d1dad.err'.
150221 05:25:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150221 05:25:21 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
root@CenturionX:/home/centurionx/Code/Git/gdms-rcon#
Run Code Online (Sandbox Code Playgroud)
为什么守护进程不保持打开状态?我有我的Dockerfile,看起来像:
# This docker file constructs a MySQL database instance
FROM mysql:latest
ADD . /gdms-rcon/mysql
WORKDIR /gdms-rcon/mysql
ENTRYPOINT ["/usr/bin/mysqld_safe"]
EXPOSE 3306
Run Code Online (Sandbox Code Playgroud)
还有一个fig.yml帮助我自动化构建过程的文件:
mysql:
build: …Run Code Online (Sandbox Code Playgroud) 在我的教科书中,我被告知排序问题的时间复杂度为 ?(n*log(n)).但是,显示Radix排序很简单O(n).这与这说不矛盾吗?因此排序问题的下限时间复杂度不是?(n)吗?
编辑:StackOverflow不会让我把"问题"放在我的标题中所以"problemo"必须留下来.
是的,我意识到有些问题与这个问题非常相似,但与其他问题不同的是,我的onCreateView()方法夸大了片段的视图。当我不使用 时findViewById(),一切都会膨胀,我的应用程序按预期工作(除了我想要进入的视图功能findViewById()。
这是我的代码:
@Override
public View onCreateView(LayoutInflater p_inflater, ViewGroup p_container, Bundle p_prev_state)
{
return p_inflater.inflate(R.layout.fragment_main, p_container, false);
}
Run Code Online (Sandbox Code Playgroud)
每当我想访问布局中的 ListView 时,我都会这样做:
private ListView getListView()
{
return (ListView)getView().findViewById(R.id.main_events);
}
Run Code Online (Sandbox Code Playgroud)
但这始终为空。为什么?我的fragment_main.xml看起来像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="me.k.cal.MainActivity$PlaceholderFragment" >
<ListView android:id="@+id/main_events"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="1dp"
android:divider="@color/background_color" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)