Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

《Programming Phoenix 1.4》 Notes #13

Open
zhulinpinyu opened this issue Dec 6, 2018 · 0 comments
Open

《Programming Phoenix 1.4》 Notes #13

zhulinpinyu opened this issue Dec 6, 2018 · 0 comments

Comments

@zhulinpinyu
Copy link
Owner

zhulinpinyu commented Dec 6, 2018

“Although applications usually have a single endpoint, Phoenix doesn’t limit the number of endpoints your application can have. For example, you could have your main application endpoint running on port 80 (HTTP) and 443 (HTTPS), as well as a specific admin endpoint running on a special port—let’s say 8080 (HTTPS)—with specific characteristics and security constraints.”

phoenix 可以设置多个入口


pipeline:browser​ ​do​
​  plug:accepts, ["​​html"]plug:fetch_session​
​  plug:fetch_flash​
​  plug:protect_from_forgery​
​  plug:put_secure_browser_headers​
​​end

pipeline就是一个plug的集合


​​iex> import​ Ecto.Changeset
​Ecto.Changeset
​
​​iex>​ changeset = put_change(changeset, ​:username​, ​"​​ericmj"​)
​%Ecto.Changeset{changes: %{username: "ericmj"}, ...}
​
​​iex>​ changeset.changes
​%{username: "ericmj"}
​
​​iex>​ get_change(changeset, ​:username​)
​"ericmj"

Ecto.Changeset 值得一试之 put_change和get_change


有两种类型的plugs

There are two kinds of plugs: module plugs and function plugs. A function plug is a single function. A module plug is a module that provides two functions with some configuration details. Either way, they work the same.

函数级别的plug就是一个函数,module级别的plug 是一个module 额外定义两个函数和一些config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant