plug_indie/README.md

49 lines
861 B
Markdown
Raw Normal View History

2024-11-29 09:42:27 +00:00
# PlugIndie
2018-03-20 05:17:02 +00:00
A small library for helping build a Plug-based Micropub server.
A basic example server that implements all [Micropub Rocks!][1] validation
tests can be found [here][2].
## Usage
Basic Usage:
```elixir
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
2024-11-29 09:42:27 +00:00
plug PlugIndie,
2018-03-20 05:17:02 +00:00
handler: MyApp.MicropubHandler,
2018-04-12 05:08:37 +00:00
json_encoder: Poison
2018-03-20 05:17:02 +00:00
```
### Forwarding
2024-11-29 09:42:27 +00:00
If you want `PlugIndie` to serve only a particular route, configure your router like:
2018-03-20 05:17:02 +00:00
#### Plug.Router
```elixir
forward "/micropub",
2024-11-29 09:42:27 +00:00
to: PlugIndie,
2018-03-20 05:17:02 +00:00
init_opts: [
handler: MyApp.MicropubHandler,
json_encoder: Poison
2018-03-20 05:17:02 +00:00
]
```
#### Phoenix.Router
```elixir
forward "/micropub",
2024-11-29 09:42:27 +00:00
PlugIndie,
2018-03-20 05:17:02 +00:00
handler: MyApp.MicropubHandler,
2018-04-12 05:08:37 +00:00
json_encoder: Poison
2018-03-20 05:17:02 +00:00
```
[1]: https://micropub.rocks/
[2]: https://github.com/bismark/micropub-example