Hawk Request Module
The hawk request module can be used to generate a Hawk header suitable for inclusion in a request to a web server that requires Hawk authentication.
https://github.com/hueniverse/hawk
1. Functions
1.1. new
Return a new header generator that can be called repeatedly to generate hawk headers to include in a request. get_header can be called on the returned table.
local hawk = require "hawk"
local hdrgen = hawk.new("myuser", "mykey", "web.host", 443)
myhdr = hdrgen:get_header("PUT", "/uri/path", "{}", "application/json")
Arguments
- id (string) - Hawk ID
- key (string) - Hawk secret
- host (string) - The hostname requests will be made to
- port (number) - The port requests will be made on
Return
- hdrgen (table) - Header generator with callable get_header function
1.2. hdrgen:get_header
Return a string usable as a Hawk header in a request.
Arguments
- method (string) - HTTP request method
- uri (string) - URI (path) for request
- payload (string) - Body of request, or nil if no body
- content-type (string) - Content type, or nil if no body
Return
- header (string) - Generated Hawk header
source code: hawk.lua