-
Notifications
You must be signed in to change notification settings - Fork 7
Add HTTP server example #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
http-server/src/Main.gren
Outdated
|
||
subscriptions : Model -> Sub Msg | ||
subscriptions model = | ||
Http.onRequest model.serverKey HandleRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, we might have different subscription functions that specialises over the requests body
type. Examples Http.onJsonRequest
or Http.onStreamRequest
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better for that to be handled with a custom type on body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it depends. But for Stream
and Byte
specifically: Stream
represents an asynchronous stream of bytes. You cannot just call a function on it and get JSON out, you'll need to handle it in a task or through some other means. For Byte
however, you can convert it directly to JSON.
Added a few comments, but ultimately think you're on the right path :) |
Starting a server can fail. Get a Permission on init (like FileSystem) and return a Task to handle failure. Based on feedback from the PR: gren-lang#13
Updated based on feedback |
Just looked over your latest changes and I think it looks good. Might want to add a |
Iterating on this API and chipping away at implementation here: blaix/gren-node#1 |
6e69b7a
to
de8f384
Compare
Finally updated this with a working example now that the HTTP server API is merged in. |
Update: Replaced with a working example now that gren-lang/node#8 is merged.
This is not functional. Looking for feedback on the API.Main thoughts: