public
Description: Erlang web application framework
Homepage: http://getsmak.com/
Clone URL: git://github.com/skarab/smak.git
Hunter Morris (author)
Wed Mar 11 18:39:28 -0700 2009
commit  ab4d7bb3cdc81ee11677769c68b01902c3cdeeda
tree    b93a7f7a14b308d182c645bd444ac5dcba42bf47
parent  47eaf1f9298f9fe5c67d029e822c095cd11209fe
smak / include / smak.hrl
100644 97 lines (75 sloc) 2.972 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
-ifndef(_SMAK_HRL).
-define(_SMAK_HRL, 1).
 
%% Include EWGI only once
-include("ewgi.hrl").
 
%% @type property() = atom() | tuple()
-type(property() :: atom() | tuple()).
 
%% @type proplist() = [property()]
-type(proplist() :: [property()]).
 
%% @type iodata() = binary() | iolist()
-type(iodata() :: binary() | iolist()).
 
%% @type ewgi_response() = iodata() | stream()
-type(ewgi_response() :: iodata() | stream()).
 
%% @type ewgi_env() = proplist()
-type(ewgi_env() :: proplist()).
 
%% @type ewgi_response_headers() = [{string(), string()}]
-type(ewgi_response_headers() :: [{string(), string()}]).
 
%% @type ewgi_write() = function()
-type(ewgi_write() :: fun((iodata()) -> ok)).
 
%% @type ewgi_start_response() = function()
-type(ewgi_start_response() :: fun((ewgi_status(), ewgi_response_headers()) -> ewgi_write())).
 
-define(IS_EWGI_APPLICATION(A), is_function(A, 1)).
 
%% Record representing each of the parts of a well-formed URL.
-record(urlparts, {
          scheme=[],
          netloc=[],
          path=[],
          params=[],
          qry=[],
          fragment=[]
         }).
 
%%----------------------------------------------------------------------
%% Calendar types (from calendar.erl in OTP R12B5)
%%----------------------------------------------------------------------
 
-type year() :: non_neg_integer().
-type year1970() :: 1970..10000. % should probably be 1970..
-type month() :: 1..12.
-type day() :: 1..31.
-type hour() :: 0..23.
-type minute() :: 0..59.
-type second() :: 0..59.
-type daynum() :: 1..7.
-type ldom() :: 28 | 29 | 30 | 31. % last day of month
 
-type t_now() :: {non_neg_integer(),non_neg_integer(),non_neg_integer()}.
 
-type t_date() :: {year(),month(),day()}.
-type t_time() :: {hour(),minute(),second()}.
-type t_datetime() :: {t_date(),t_time()}.
-type t_datetime1970() :: {{year1970(),month(),day()},t_time()}.
 
%%----------------------------------------------------------------------
%% Helper macros
%%----------------------------------------------------------------------
-define(EWGI_LOGGER_NAME, smak_logger).
-define(EWGI_LOGGER_KEY, '_smak_logger').
-define(CTX_LOG(Ctx, L, F, A),
        case ewgi_api:find_data(?EWGI_LOGGER_KEY, Ctx) of
            Log when is_function(Log, 3) ->
                Log(L, F, A);
            _ ->
                ok % silently ignore
        end).
 
-type log_level() :: 'error' | 'info' | 'debug' | 'verbose'.
 
-record(media_type, {
          mime :: string(),
          description :: string(),
          parameters=[] :: [{string(), string()}]
         }).
 
-define(ROUTE_KEY, '_smak_route').
-define(ROUTE_TREE_KEY, '_smak_routes').
-define(ROUTE_PATH_KEY, '_smak_routepath').
 
%% @type route_name() = string()
-type route_name() :: string().
%% @type route_pmatch() = {atom(), string()}
-type route_pmatch() :: {atom(), string()}.
%% @type route_pmatches() = [route_pmatch()]
-type route_pmatches() :: [route_pmatch()].
 
-endif.