Nim: please implement http put and delete in httpClient

Created on 25 Aug 2018  路  8Comments  路  Source: nim-lang/Nim

  • Implement HTTP PUT and DELETE methods on httpClient and asyncHttpClient.
Easy Feature Stdlib

Most helpful comment

It would be nice just to have:

  • httpClient.put()
  • httpClient.delete()
  • asyncHttpClient.put()
  • asyncHttpClient.delete()

Yes I know theres workaround and hacks you can use on your own code, also some API use an HTTP header to "fake" a PUT with a POST, but even more if you say theres super easy to implement, then would be nice to have, instead of additional hacks, I am not complaining about the design or anything else, I just say would be nice to have those useful procs in.
:cat:

All 8 comments

I don't understand, does it not work?

Theres no HTTP PUT and DELETE methods on httpClient and asyncHttpClient.

There's no put or delete proc, but you still can use PUT and DELETE.

import httpclient, asyncdispatch

let client = newAsyncHttpClient()
let response = await client.request("http://httpbin.org/put", HttpPut)

The HTTP method enum is in the httpcore module which httpclient exports but I guess that might be hard to find in the documentation. If you want to add put and delete alias procs to httpclient you can define them in your own code.

It would be nice just to have:

  • httpClient.put()
  • httpClient.delete()
  • asyncHttpClient.put()
  • asyncHttpClient.delete()

Yes I know theres workaround and hacks you can use on your own code, also some API use an HTTP header to "fake" a PUT with a POST, but even more if you say theres super easy to implement, then would be nice to have, instead of additional hacks, I am not complaining about the design or anything else, I just say would be nice to have those useful procs in.
:cat:

I'm going to take a look at this over the next few days. Good idea.

I appreciate the quick response and the good work, keep it up :grey_exclamation: :smile_cat:

This should be fairly easy to solve.

Simply replicate the get and post procs, change the HTTP method that they are using and that should be all that's needed. These procedures are just simple aliases for what @hlaaftana showed.

Thanks everyone for the excellent work, the improvements really make a less verbose and human code. :slightly_smiling_face:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hlaaftana picture hlaaftana  路  3Comments

hlaaftana picture hlaaftana  路  3Comments

zaxebo1 picture zaxebo1  路  4Comments

SolitudeSF picture SolitudeSF  路  3Comments

ghost picture ghost  路  4Comments