-
Notifications
You must be signed in to change notification settings - Fork 2
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
add a form #9
Open
brandly
wants to merge
1
commit into
meangrape:master
Choose a base branch
from
brandly:patch-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add a form #9
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I like the idea of using Content-Type & non-inline content. However I defer
to @mitchellwrosen for architectural guidance since Haskell + FE stuff is
something I barely know added to something I don’t know.
On Sat, Mar 17, 2018 at 2:31 PM Matthew Brandly ***@***.***> wrote:
right now, POST /links expects JSON data, so here are our options:
- change endpoint to take name and url from
application/x-www-form-urlencoded data, and change <form> to <form
action="/links">
- add some JS to the page to post JSON, but i'd like some way to write
a .js file that gets inlined, instead of writing JS in a haskell
string. the JS would look something like
document.querySelector('form')
.addEventListener('submit', function (e) {
e.preventDefault();
const body = Array.from(e.target.elements)
.filter(el => el.type !== 'submit')
.reduce((out, el) => {
out[el.name] = el.value
return out
}, {});
fetch('/links', {
method: 'POST',
body: JSON.stringify(body)
}).then(r => {
if (r.ok) {
window.location.reload();
} else {
console.error(r);
}
});
});
i vote for the first option. we could look at content-type and accept
either JSON or form data. i'm not sure how to do these things in haskell,
cc @mitchellwrosen <https://github.com/mitchellwrosen>
------------------------------
You can view, comment on, or merge this pull request online at:
#9
Commit Summary
- add a nonfunctional form
File Changes
- *M* app/Main.hs <https://github.com/jayed/gogurl/pull/9/files#diff-0>
(1)
Patch Links:
- https://github.com/jayed/gogurl/pull/9.patch
- https://github.com/jayed/gogurl/pull/9.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAjeyBUu-lSGthMGaBufSIe04ty5BmPks5tfVaMgaJpZM4Su6bu>
.
--
Jay Edwards | @meangrape | [email protected]
|
Sure, option 1 sounds good |
I opened scotty-web/scotty#216 so this is more of a one-liner for us |
I created a new branch, link-form, and merged this PR there. I don't want to merge non-working code into master. We'll keep this open while we resolve things and see how the scotty PR goes. Thanks, all! |
@brandly Here's a pointer to static content in Scotty. A few years old but looks like a good start. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
right now,
POST /links
expects JSON data, so here are our options:name
andurl
fromapplication/x-www-form-urlencoded
data, and change<form>
to<form action="/links">
.js
file that gets inlined, instead of writing JS in a haskell string. the JS would look something likei vote for the first option. we could look at
content-type
and accept either JSON or form data. i'm not sure how to do these things in haskell, cc @mitchellwrosen