Hi everybody, I’m new to Elixir (from Mobile app)
I have an API get question list, this api allow login - non login user get list of question. The Login user can UpVote or DownVote (like Reddit or StackOverflow). I’m using Guardian to let user login by Google and return JWT using to auth.
My problem is I need an ID of login user to see table question_vote contain it or not to determine the question will be up-voteable or down-voteable.
In my router.ex
scope "/api/v1", LiuloWeb do pipe_through :api post "/login_google", AuthController, :callback resources "/topic", TopicController, only: [:show] do get "/question", QuestionController, :question_by_topic end end scope "/api/v1", LiuloWeb do pipe_through [:api, :api_auth] resources "/topic", TopicController, except: [:new, :edit] do get "/question", QuestionController, :question_by_topic end end
The code above alway patten matching to
pipe_through :api only, that why I can’t get logging user by
Is there any way to determine which pipe_throught base on request header or better way to handle this? Some people said I should split to 2 api for login and non login user, is it a best way?