title: Parsing HTTP multipart POST using a struct in Rocket
body: <p>I want to parse a HTTP POST in Rocket using a struct. Upon submitting the form it fails.</p>
  
  <p>I read the <a href="https://rocket.rs/guide/requests/#body-data" rel="nofollow noreferrer">body data</a> example and have this code.</p>
  
  <pre><code>#[derive(FromForm)]
  struct ConvertFile {
      name: String,
      filename: String
  }
  
  #[post("/submit", format = "multipart/form-data", data = "&lt;form&gt;")]
  fn submit(form: Form&lt;ConvertFile&gt;) {
      println!("form field: {}", form.get().name);
  }
  </code></pre>
  
  <p>I submit using curl:</p>
  
  <pre class="lang-none prettyprint-override"><code>curl -H "Content-Type: multipart/form-data" -F "name=Claus" -F "filename=claus.jpg" http://localhost:8000/submit
  </code></pre>
  
  <p>and the Rocket console responds with</p>
  
  <pre class="lang-none prettyprint-override"><code>multipart/form-data; boundary=------------------------8495649d6ed34d20:
      =&gt; Matched: POST /submit multipart/form-data
      =&gt; Warning: Form data does not have form content type.
      =&gt; Outcome: Forward
      =&gt; Error: No matching routes for POST /submit multipart/form-data; boundary=------------------------8495649d6ed34d2.
      =&gt; Warning: Responding with 404 Not Found catcher.
      =&gt; Response succeeded.
  </code></pre>
  
  <p>I want to submit a file hence the <code>multipart/form-data</code>. When trying to find the reason, I used a <code>String</code> in the struct to make it simpler. So first it responds with a <code>Matched:</code> and then no matching routes.</p>
  
  <p>This simpler POST works:</p>
  
  <pre><code>#[post("/convert", format = "text/plain", data = "&lt;file&gt;")]
  fn convert_file(file: String) {
      println!("file: {}", file);
  }
  </code></pre>
  
  <p>I am using the latest nightly Rust with rustup.</p>
  
  <p>What am I doing wrong?</p>