Skip to content

Latest commit

 

History

History
409 lines (206 loc) · 8.87 KB

sc_push_wm_helper.md

File metadata and controls

409 lines (206 loc) · 8.87 KB

Module sc_push_wm_helper

webmachine helper functions.

Authors: Edwin Fine (efine@silentcircle.com).

Description

See https://github.com/basho/webmachine/wiki/Resource-Functions for a description of the resource functions used in this module.

Data Types


config() = pl(atom(), term())

A config property list.


debug_info() = ok | {trace, filepath()}

Webmachine: possible returns from init/1.


ejson() = ejson_term()

ejson_collection() = ejson_list() | ejson_dict()

ejson_dict() = ejson_empty_dict() | [ejson_field()]

ejson_empty_dict() = [{}]

ejson_field() = {ejson_field_name(), ejson_term()}

ejson_field_name() = atom() | unicode()

ejson_list() = [ejson_term()]

ejson_scalar() = boolean() | null | number() | unicode()

filepath() = string()

json() = binary()

pl(KT, VT) = [{KT, VT}]

Property list.


unicode() = binary()

wbool_ret() = wret(boolean())

Webmachine: boolean dispatch function return type.


werr() = {error, iolist()}

Webmachine: dispatch function returns this to signal 500 error.


wiolist_ret() = wret(iolist())

Webmachine: iolist dispatch function return type.


wret(T) = {T | werr(), wrq(), any()}

Webmachine: dispatch functions return this.


wrq() = #wm_reqdata{}

Webmachine: request data record.

Function Index

add_seps/2
bad_json_error/0
check_reg_lookup/1Check the return of the sc_push_reg_api lookup.
config_debug/1Check if config contains {debug, TraceFilePath} and return {trace, TraceFilePath} if so, ok if not.
ejson_to_props/1
enc_headers/1
encode_props/1
get_device_id/1
get_req_hdr/2
get_req_hdr/3
get_svc_id/1
is_debug/2
is_valid_reg_req/1
is_valid_service_id/2
make_service_id_path/1
make_service_id_url/2Return service/token URL as binary string.
make_service_id_urls/2Create a list of binary resource URLs from the property lists to be returned.
malformed_err/2
parse_json/1
pv/3
sanctify/1

Function Details

add_seps/2

add_seps(List, Sep) -> any()

bad_json_error/0

bad_json_error() -> any()

check_reg_lookup/1

check_reg_lookup(Error) -> any()

Check the return of the sc_push_reg_api lookup

config_debug/1


config_debug(Config::config()) -> debug_info()

Check if config contains {debug, TraceFilePath} and return {trace, TraceFilePath} if so, ok if not.

ejson_to_props/1

ejson_to_props(EJSON) -> any()

enc_headers/1

enc_headers(T) -> any()

encode_props/1

encode_props(Props) -> any()

get_device_id/1


get_device_id(ReqData::wrq()) -> {ok, any()} | undefined

get_req_hdr/2


get_req_hdr(HeaderName::string(), ReqData::wrq()) -> string() | undefined

get_req_hdr/3


get_req_hdr(HeaderName::string(), ReqData::wrq(), Default::string()) -> string()

get_svc_id/1


get_svc_id(ReqData::wrq()) -> {ok, any()} | undefined

is_debug/2


is_debug(ReqData::wrq(), Cfg::list()) -> boolean()

is_valid_reg_req/1


is_valid_reg_req(EJSON::ejson()) -> boolean()

is_valid_service_id/2

is_valid_service_id(Svc, Token) -> any()

make_service_id_path/1

make_service_id_path(Proplist) -> any()

make_service_id_url/2

make_service_id_url(BaseURI, Proplist) -> any()

Return service/token URL as binary string.

make_service_id_urls/2

make_service_id_urls(ReqData, Proplists) -> any()

Create a list of binary resource URLs from the property lists to be returned. The URLs will be urlencoded.

malformed_err/2


malformed_err(Error::iolist() | binary(), ReqData::wrq()) -> wrq()

parse_json/1


parse_json(X1::json()) -> {ok, ejson()} | {bad_json, string()}

pv/3

pv(K, PL, Def) -> any()

sanctify/1

sanctify(PathComponent) -> any()