3131
3232% % @doc Get default value by Key.
3333-spec default (DefaultID , Context ) -> Result when
34- DefaultID :: service_available | resource_exists | auth_required | is_authorized | forbidden | upgrades_provided | allow_missing_post | malformed_request | uri_too_long | known_content_type | valid_content_headers | valid_entity_length | options | allowed_methods | known_methods | validate_content_checksum | content_types_provided | content_types_accepted | delete_resource | delete_completed | post_is_create | create_path | base_uri | process_post | language_available | charsets_provided | content_encodings_provided | transfer_encodings_provided | variances | is_conflict | multiple_choices | previously_existed | moved_permanently | moved_temporarily | last_modified | expires | generate_etag | finish_request ,
35- Context :: cowmachine_req :context (),
36- Result :: no_charset | no_default | undefined | boolean () | list (binary ()).
34+ DefaultID :: service_available | resource_exists | auth_required | is_authorized |
35+ forbidden | upgrades_provided | allow_missing_post | malformed_request |
36+ uri_too_long | known_content_type | valid_content_headers | valid_entity_length |
37+ options | allowed_methods | known_methods | validate_content_checksum |
38+ content_types_provided | content_types_accepted | delete_resource | delete_completed |
39+ post_is_create | create_path | base_uri | process_post | language_available |
40+ charsets_provided | content_encodings_provided | transfer_encodings_provided |
41+ variances | is_conflict | multiple_choices | previously_existed | moved_permanently |
42+ moved_temporarily | last_modified | expires | generate_etag | finish_request ,
43+ Context :: cowmachine_req :context (),
44+ Result :: no_charset | no_default | undefined | boolean () | list (binary ()).
3745default (service_available , _Context ) ->
3846 true ;
3947default (resource_exists , _Context ) ->
@@ -134,8 +142,8 @@ default(_, _Context) ->
134142% % @doc Content types that are textual and should have a charset defined.
135143
136144-spec is_text (ContentType ) -> Result when
137- ContentType :: cow_http_hd :media_type (),
138- Result :: boolean ().
145+ ContentType :: cow_http_hd :media_type (),
146+ Result :: boolean ().
139147is_text ({<<" text" >>, _ , _ }) -> true ;
140148is_text ({<<" application" >>, <<" json" >>, _ }) -> true ;
141149is_text ({<<" application" >>, <<" ld+json" >>, _ }) -> true ;
@@ -157,11 +165,11 @@ is_text(_) ->
157165% % @doc Export and run function `Fun'.
158166
159167-spec do (Fun , State , Context ) -> Result when
160- Fun :: atom (),
161- State :: cmstate (),
162- Context :: cowmachine_req :context (),
163- Result :: {ContentType , Context },
164- ContentType :: cow_http_hd :media_type ().
168+ Fun :: atom (),
169+ State :: cmstate (),
170+ Context :: cowmachine_req :context (),
171+ Result :: {ContentType , Context },
172+ ContentType :: cow_http_hd :media_type ().
165173do (Fun , # cmstate { controller = Controller }, Context ) when is_atom (Fun ) ->
166174 case erlang :function_exported (Controller , Fun , 1 ) of
167175 true ->
@@ -176,12 +184,12 @@ do(Fun, #cmstate{ controller = Controller }, Context) when is_atom(Fun) ->
176184% % @doc Export and process `State' with `Context'.
177185
178186-spec do_process (ContentType , State , Context ) -> Result when
179- ContentType :: cow_http_hd :media_type (),
180- State :: cmstate (),
181- Context :: cowmachine_req :context (),
182- Result :: {Res , Context },
183- Res :: boolean () | cowmachine_req :halt () | {error , any (), any ()} | {error , any ()} |
184- cowmachine_req :resp_body ().
187+ ContentType :: cow_http_hd :media_type (),
188+ State :: cmstate (),
189+ Context :: cowmachine_req :context (),
190+ Result :: {Res , Context },
191+ Res :: boolean () | cowmachine_req :halt () | {error , any (), any ()} | {error , any ()} |
192+ cowmachine_req :resp_body ().
185193do_process (ContentType , # cmstate { controller = Controller }, Context ) ->
186194 case erlang :function_exported (Controller , process , 4 ) of
187195 true ->
0 commit comments