* luci/libs/http: added inline documentation to luci.http.protocol & friends, fixed...
[project/luci.git] / libs / http / luasrc / http / protocol / mime.lua
index 9fb8d256de8d97ff35a2afc6af32e9ee665d02ae..9722dde42a77beaf0d27d47856eb42fe22f518a1 100644 (file)
@@ -13,12 +13,15 @@ $Id$
 
 ]]--
 
+--- LuCI http protocol implementation - mime helper class.
+-- This class provides functions to guess mime types from file extensions and
+-- vice versa.
 module("luci.http.protocol.mime", package.seeall)
 
 require("luci.util")
 
-
--- MIME mapping
+--- MIME mapping table containg extension - mimetype relations.
+-- @class table
 MIME_TYPES = {
     ["txt"]   = "text/plain";
     ["js"]    = "text/javascript";
@@ -62,8 +65,10 @@ MIME_TYPES = {
     ["avi"]   = "video/x-msvideo";
 }
 
--- extract extension from a filename and return corresponding mime-type or
--- "application/octet-stream" if the extension is unknown
+--- Extract extension from a filename and return corresponding mime-type or
+-- "application/octet-stream" if the extension is unknown.
+-- @param filename     The filename for which the mime type is guessed
+-- @return                     String containign the determined mime type
 function to_mime(filename)
        if type(filename) == "string" then
                local ext = filename:match("[^%.]+$")
@@ -76,8 +81,10 @@ function to_mime(filename)
        return "application/octet-stream"
 end
 
--- return corresponding extension for a given mime type or nil if the
--- given mime-type is unknown
+--- Return corresponding extension for a given mime type or nil if the
+-- given mime-type is unknown.
+-- @param mimetype     The mimetype to retrieve the extension from
+-- @return                     String with the extension or nil for unknown type
 function to_ext(mimetype)
        if type(mimetype) == "string" then
                for ext, type in luci.util.kspairs( MIME_TYPES ) do