diff options
Diffstat (limited to 'src/guff/api/util.cr')
-rw-r--r-- | src/guff/api/util.cr | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/guff/api/util.cr b/src/guff/api/util.cr new file mode 100644 index 0000000..525f098 --- /dev/null +++ b/src/guff/api/util.cr @@ -0,0 +1,31 @@ +require "json" + +module Guff + module API + module Util + private def get_site(context : HTTP::Server::Context) : Int? + @models.site.to_site(context.request.headers["host"]?) + end + + private def get_tags( + s : String? + ) : Array(String) + if s && s.size > 0 + Array(String).from_json(s) + else + [] of String + end + end + + private def get_posts_tags( + s : String? + ) : Array(Array(String)) + if s && s.size > 0 + Array(Array(String)).from_json(s) + else + [] of Array(String) + end + end + end + end +end |