Giter Club home page Giter Club logo

Comments (7)

adamstep avatar adamstep commented on July 21, 2024

Hi @rickheere, thanks for checking out the project. The approach you describe (looking at the Accept header to switch between HTML and Hyperview templates) works really well! We do that ourselves in some of our apps.

You are correct that we only support GET and POST right now, this was based on how HTML forms work. We didn't plan to add support for other HTTP methods, but it is something we could do if it makes it easier to use.

What language/framework are you using for your backend? Many frameworks support passing the method as a query param, eg POST /resource/123?method=delete. Happy to help here.

from hyperview.

rickheere avatar rickheere commented on July 21, 2024

Thank you for the reply @adamstep. Adding the method as an parameter to get around my problem is a smart idea. I'm using nodejs with Express, I tested it out and I can just manually override the method value with some early middleware. There is even a middleware mentioned on the website Express.

from hyperview.

rickheere avatar rickheere commented on July 21, 2024

I do however have another issue. If you want me to move it to a new ticket let me know. I menage to do a POST request but it looks like my setup is not able to parse the body. I'm using body-parser which is the go to library to parse the body. I set it up in a way to look for all typ's it supports and try to parse those, this is the default interface of the library

bodyParser()

I get an empty body object, this is the default response of the library if there is no body. The content-type coming in says it we are dealing with a "multipart/form-data; boundary=df2cf318-a7e6-4a73-b315-ff04b3619d0e". Looking around a bit it seems like people add the multer to be able to parse these. I configure it with the .none() option because the docs say this is for parsing fields and does not accept any file uploads.

const upload = multer()
...
...
  bodyParser(),
  upload.none(),

Now I get an error parsing the body.

[node] index-0  | Error: Unexpected end of form
[node] index-0  |     at Multipart._final (/home/rick/Repositories/ctoa-platform/node_modules/busboy/lib/types/multipart.js:588:17)
[node] index-0  |     at callFinal (node:internal/streams/writable:694:27)
[node] index-0  |     at prefinish (node:internal/streams/writable:723:7)
[node] index-0  |     at finishMaybe (node:internal/streams/writable:733:5)
[node] index-0  |     at Multipart.Writable.end (node:internal/streams/writable:631:5)
[node] index-0  |     at onend (node:internal/streams/readable:693:10)
[node] index-0  |     at processTicksAndRejections (node:internal/process/task_queues:78:11)

Doe you know where it goes wrong here?

photo_5836788018017581588_y

from hyperview.

rickheere avatar rickheere commented on July 21, 2024

Alright I had some time to continue with the project again. I got the multipart request parsing to work with fine with connect-multiparty

from hyperview.

adamstep avatar adamstep commented on July 21, 2024

Thanks for the update @rickheere. Glad it the request parsing works now. Multipart form data will help us support file uploads too like outlined in this issue: #300 . We are also considering adding more verb support so I'll leave this open for now.

from hyperview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.