From 85c46f927f20930c4cf2682ff9b5dd6ce4cac48f Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Wed, 11 Apr 2018 22:50:37 -0700 Subject: [PATCH] Small fixes - Use plug formatter - Add fallback match - Remove tabs! --- .formatter.exs | 3 ++- README.md | 4 ++-- lib/plug_micropub.ex | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 525446d..9f411ac 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,5 @@ # Used by "mix format" [ - inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"], + import_deps: [:plug] ] diff --git a/README.md b/README.md index 561ba08..b998f34 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ If you want `PlugMicropub` to serve only a particular route, configure your rout forward "/micropub", to: PlugMicropub, init_opts: [ - handler: MyApp.MicropubHandler, - json_encoder: Poison + handler: MyApp.MicropubHandler, + json_encoder: Poison ] ``` diff --git a/lib/plug_micropub.ex b/lib/plug_micropub.ex index 6bb8ce7..4f553b8 100644 --- a/lib/plug_micropub.ex +++ b/lib/plug_micropub.ex @@ -7,8 +7,8 @@ defmodule PlugMicropub do """ use Plug.Router - plug(:match) - plug(:dispatch) + plug :match + plug :dispatch # Plug Callbacks @@ -64,6 +64,10 @@ defmodule PlugMicropub do end end + match _ do + send_error(conn, {:error, :invalid_request}) + end + # Internal Functions defp send_content(conn, content) do