Adapted from RPC-based plugins in Go by Eli Bendersky 🚀
Golang Plugin development + testing using the go-plugin
package from HashiCorp
First start the server:
➜ git clone https://github.com/ohsu-comp-bio/plugins
➜ cd plugins
➜ make
Building ./authorize...OK
➜ ./authorize
Listening on http://localhost:8080
In another terminal, send the request using of the example users below:
➜ curl -H "Authorization: Bearer Alyssa P. Hacker" http://localhost:8080
User: Alyssa P. Hacker, Token: <Alyssa's Secret> ✅
Here's an example of a user that's not found by the plugin (representing an Unauthorized
user):
➜ curl -H "Authorization: Bearer Foobar" http://localhost:8080
Error: User Foobar not found ❌
Example users may be found in example-users.csv:
- Alyssa P. Hacker, a Lisp hacker
- Ben Bitdiddle
- Cy D. Fect, a "reformed C programmer"
- Eva Lu Ator
- Lem E. Tweakit
- Louis Reasoner, a loose reasoner