Skip to content

Instantly share code, notes, and snippets.

View jorgevilaca82's full-sized avatar
🏠
Working from home

Jorge Vilaça jorgevilaca82

🏠
Working from home
View GitHub Profile
@jorgevilaca82
jorgevilaca82 / external_routes.ex
Created April 26, 2024 15:49
map routes of an external service to use as phoenix routes
defmodule ExternalAPIRouter do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
scope "/api/v1" do
get("me2", __MODULE__, :me)
get("product/:product_id", __MODULE__, :product_detail)
end
defmodule ExternalUser do
use Ecto.Schema
import Ecto.Changeset
@primary_key false
embedded_schema do
field(:first_name, :string)
field(:last_name, :string)
end
@jorgevilaca82
jorgevilaca82 / error.ex
Created October 9, 2024 14:52
Error module
defmodule Error do
defstruct code: nil, message: nil, details: nil
@doc """
Creates a new error struct
## Usage:
iex> Error.new("E001", "This is an error")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.