Browse Source

Remove the REST known_content_type callback

This callback was simply useless.
Loïc Hoguin 10 years ago
parent
commit
4bc8e330fa

+ 0 - 3
ROADMAP.md

@@ -52,9 +52,6 @@ functions and the new response function described above.
 
 
 ### REST
 ### REST
 
 
-The `known_content_type` callback has no purpose, so it
-is going to be removed.
-
 The documentation for all REST callbacks will be updated
 The documentation for all REST callbacks will be updated
 to describe whether they can have side effects. This will
 to describe whether they can have side effects. This will
 allows us to build introspection tools on top of a working
 allows us to build introspection tools on top of a working

+ 0 - 1
doc/src/guide/rest_handlers.ezdoc

@@ -67,7 +67,6 @@ if it is undefined, moving directly to the next step. Similarly,
 |	generate_etag			`undefined`
 |	generate_etag			`undefined`
 |	is_authorized			`true`
 |	is_authorized			`true`
 |	is_conflict				`false`
 |	is_conflict				`false`
-|	known_content_type		`true`
 |	known_methods			`[<<"GET">>, <<"HEAD">>, <<"POST">>, <<"PUT">>, <<"PATCH">>, <<"DELETE">>, <<"OPTIONS">>]`
 |	known_methods			`[<<"GET">>, <<"HEAD">>, <<"POST">>, <<"PUT">>, <<"PATCH">>, <<"DELETE">>, <<"OPTIONS">>]`
 |	languages_provided		skip
 |	languages_provided		skip
 |	last_modified			`undefined`
 |	last_modified			`undefined`

BIN
doc/src/guide/rest_start.png


+ 5 - 117
doc/src/guide/rest_start.svg

@@ -16,7 +16,7 @@
    id="svg2"
    id="svg2"
    version="1.1"
    version="1.1"
    inkscape:version="0.48.4 r9939"
    inkscape:version="0.48.4 r9939"
-   sodipodi:docname="rest_options.svg"
+   sodipodi:docname="rest_start.svg"
    inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png"
    inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png"
    inkscape:export-xdpi="90"
    inkscape:export-xdpi="90"
    inkscape:export-ydpi="90">
    inkscape:export-ydpi="90">
@@ -93,7 +93,7 @@
         <dc:format>image/svg+xml</dc:format>
         <dc:format>image/svg+xml</dc:format>
         <dc:type
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
+        <dc:title />
       </cc:Work>
       </cc:Work>
     </rdf:RDF>
     </rdf:RDF>
   </metadata>
   </metadata>
@@ -370,32 +370,6 @@
          sodipodi:type="star" />
          sodipodi:type="star" />
     </g>
     </g>
     <g
     <g
-       transform="translate(205.92143,541.19345)"
-       id="g5650-10">
-      <path
-         inkscape:connector-curvature="0"
-         id="path5570-8"
-         d="m -57.78256,351.41962 0,52.3259"
-         style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
-      <path
-         transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)"
-         inkscape:transform-center-y="2.1823437"
-         d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z"
-         inkscape:randomized="0"
-         inkscape:rounded="0"
-         inkscape:flatsided="true"
-         sodipodi:arg2="2.6179939"
-         sodipodi:arg1="1.5707963"
-         sodipodi:r2="7.4246211"
-         sodipodi:r1="14.849242"
-         sodipodi:cy="415.25897"
-         sodipodi:cx="-222.73865"
-         sodipodi:sides="3"
-         id="path5576-8"
-         style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
-         sodipodi:type="star" />
-    </g>
-    <g
        transform="matrix(0,-1,1,0,-25.673146,80.832304)"
        transform="matrix(0,-1,1,0,-25.673146,80.832304)"
        id="g5650-2-0">
        id="g5650-2-0">
       <path
       <path
@@ -629,32 +603,6 @@
          style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
          style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
          sodipodi:type="star" />
          sodipodi:type="star" />
     </g>
     </g>
-    <g
-       transform="matrix(0,-1,1,0,-25.673146,833.83768)"
-       id="g5650-2-34">
-      <path
-         inkscape:connector-curvature="0"
-         id="path5570-2-62"
-         d="m -57.78256,275.13761 0,129.13992"
-         style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
-      <path
-         transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)"
-         inkscape:transform-center-y="2.1823437"
-         d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z"
-         inkscape:randomized="0"
-         inkscape:rounded="0"
-         inkscape:flatsided="true"
-         sodipodi:arg2="2.6179939"
-         sodipodi:arg1="1.5707963"
-         sodipodi:r2="7.4246211"
-         sodipodi:r1="14.849242"
-         sodipodi:cy="415.25897"
-         sodipodi:cx="-222.73865"
-         sodipodi:sides="3"
-         id="path5576-12-62"
-         style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
-         sodipodi:type="star" />
-    </g>
     <rect
     <rect
        style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        id="rect5273-1-28"
        id="rect5273-1-28"
@@ -729,14 +677,6 @@
        rx="15" />
        rx="15" />
     <rect
     <rect
        style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
-       id="rect5273-1-54"
-       width="210.17955"
-       height="35.209244"
-       x="43.049091"
-       y="957.68292"
-       rx="15" />
-    <rect
-       style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        id="rect5273-1"
        id="rect5273-1"
        width="210.17955"
        width="210.17955"
        height="35.209244"
        height="35.209244"
@@ -938,7 +878,7 @@
          sodipodi:role="line"
          sodipodi:role="line"
          id="tspan5373-6-1"
          id="tspan5373-6-1"
          x="147.83809"
          x="147.83809"
-         y="812.14441">known_content_type</tspan></text>
+         y="812.14441">valid_entity_length</tspan></text>
     <text
     <text
        xml:space="preserve"
        xml:space="preserve"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
@@ -949,18 +889,7 @@
          sodipodi:role="line"
          sodipodi:role="line"
          id="tspan5373-6-71"
          id="tspan5373-6-71"
          x="148.58809"
          x="148.58809"
-         y="895.81165">valid_entity_length</tspan></text>
-    <text
-       xml:space="preserve"
-       style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
-       x="148.092"
-       y="979.7016"
-       id="text5371-2-39"
-       sodipodi:linespacing="125%"><tspan
-         sodipodi:role="line"
-         id="tspan5373-6-6"
-         x="148.092"
-         y="979.7016">...</tspan></text>
+         y="895.81165">...</tspan></text>
     <text
     <text
        xml:space="preserve"
        xml:space="preserve"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
@@ -1101,17 +1030,6 @@
          id="tspan5373-6-9"
          id="tspan5373-6-9"
          x="164.26562"
          x="164.26562"
          y="855.29053">true</tspan></text>
          y="855.29053">true</tspan></text>
-    <text
-       xml:space="preserve"
-       style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
-       x="164.26562"
-       y="938.95776"
-       id="text5371-2-22"
-       sodipodi:linespacing="125%"><tspan
-         sodipodi:role="line"
-         id="tspan5373-6-57"
-         x="164.26562"
-         y="938.95776">true</tspan></text>
     <g
     <g
        transform="matrix(0,-1,1,0,-513.31414,353.05561)"
        transform="matrix(0,-1,1,0,-513.31414,353.05561)"
        id="g5650-2">
        id="g5650-2">
@@ -1237,17 +1155,6 @@
          id="tspan5373-9-012"
          id="tspan5373-9-012"
          x="315.26172"
          x="315.26172"
          y="791.42102">false</tspan></text>
          y="791.42102">false</tspan></text>
-    <text
-       xml:space="preserve"
-       style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
-       x="315.26172"
-       y="874.86609"
-       id="text5371-4-38"
-       sodipodi:linespacing="125%"><tspan
-         sodipodi:role="line"
-         id="tspan5373-9-67"
-         x="315.26172"
-         y="874.86609">false</tspan></text>
     <rect
     <rect
        style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        id="rect5273-7-3"
        id="rect5273-7-3"
@@ -1331,14 +1238,6 @@
        x="392.03732"
        x="392.03732"
        y="790.78027"
        y="790.78027"
        rx="15" />
        rx="15" />
-    <rect
-       style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
-       id="rect5273-7-3-29"
-       width="264.92532"
-       height="34.728001"
-       x="392.03732"
-       y="874.47223"
-       rx="15" />
     <text
     <text
        xml:space="preserve"
        xml:space="preserve"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
        style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
@@ -1426,18 +1325,7 @@
          sodipodi:role="line"
          sodipodi:role="line"
          id="tspan5373-60"
          id="tspan5373-60"
          x="524.26172"
          x="524.26172"
-         y="813.64819">415 unsupported media type</tspan></text>
-    <text
-       xml:space="preserve"
-       style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
-       x="524.26172"
-       y="897.34015"
-       id="text5371-0"
-       sodipodi:linespacing="125%"><tspan
-         sodipodi:role="line"
-         id="tspan5373-0"
-         x="524.26172"
-         y="897.34015">413 request entity too large</tspan></text>
+         y="813.64819">413 request entity too large</tspan></text>
     <rect
     <rect
        style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
        id="rect5367"
        id="rect5367"

+ 0 - 11
doc/src/manual/cowboy_rest.ezdoc

@@ -311,17 +311,6 @@ Return whether the put action results in a conflict.
 A `409 Conflict` response will be sent if this function
 A `409 Conflict` response will be sent if this function
 returns `true`.
 returns `true`.
 
 
-: known_content_type
-
-* Methods: all
-* Value type: boolean()
-* Default value: true
-
-Return whether the content-type is known.
-
-This function determines if the server understands the
-content-type, regardless of its use by the resource.
-
 : known_methods
 : known_methods
 
 
 * Methods: all
 * Methods: all

+ 1 - 5
src/cowboy_rest.erl

@@ -155,11 +155,7 @@ forbidden(Req, State) ->
 
 
 valid_content_headers(Req, State) ->
 valid_content_headers(Req, State) ->
 	expect(Req, State, valid_content_headers, true,
 	expect(Req, State, valid_content_headers, true,
-		fun known_content_type/2, 501).
-
-known_content_type(Req, State) ->
-	expect(Req, State, known_content_type, true,
-		fun valid_entity_length/2, 415).
+		fun valid_entity_length/2, 501).
 
 
 valid_entity_length(Req, State) ->
 valid_entity_length(Req, State) ->
 	expect(Req, State, valid_entity_length, true, fun options/2, 413).
 	expect(Req, State, valid_entity_length, true, fun options/2, 413).