Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notes-app
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abhay Menon
notes-app
Commits
39eb96e1
Commit
39eb96e1
authored
1 year ago
by
thaihoangdang
Browse files
Options
Downloads
Patches
Plain Diff
fix Note class issue
parent
ae2df386
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Http request
Pipeline
#89242
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utilities/src/main/kotlin/notes/multi/utilities/HttpOperations.kt
+12
-4
12 additions, 4 deletions
...s/src/main/kotlin/notes/multi/utilities/HttpOperations.kt
with
12 additions
and
4 deletions
utilities/src/main/kotlin/notes/multi/utilities/HttpOperations.kt
+
12
−
4
View file @
39eb96e1
...
...
@@ -16,11 +16,14 @@ class HttpOperations {
.
GET
()
.
build
()
val
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
())
return
response
.
body
()
}
fun
post
(
note
:
RemoteNote
):
String
{
val
jsonNote
=
Klaxon
().
toJsonString
(
note
)
fun
post
(
note
:
Note
):
String
{
val
tempNote
=
RemoteNote
(
note
.
id
,
note
.
title
,
note
.
text
.
toString
(),
note
.
dateCreated
,
note
.
lastModified
)
val
jsonNote
=
Klaxon
().
toJsonString
(
tempNote
)
val
client
=
HttpClient
.
newBuilder
().
build
()
val
request
=
HttpRequest
.
newBuilder
()
.
uri
(
URI
.
create
(
"http://localhost:8080/notes/"
))
...
...
@@ -28,11 +31,14 @@ class HttpOperations {
.
POST
(
HttpRequest
.
BodyPublishers
.
ofString
(
jsonNote
))
.
build
()
val
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
())
return
response
.
body
()
}
fun
put
(
note
:
RemoteNote
):
String
{
val
jsonNote
=
Klaxon
().
toJsonString
(
note
)
fun
put
(
note
:
Note
):
String
{
val
tempNote
=
RemoteNote
(
note
.
id
,
note
.
title
,
note
.
text
.
toString
(),
note
.
dateCreated
,
note
.
lastModified
)
val
jsonNote
=
Klaxon
().
toJsonString
(
tempNote
)
val
client
=
HttpClient
.
newBuilder
().
build
()
val
request
=
HttpRequest
.
newBuilder
()
.
uri
(
URI
.
create
(
"http://localhost:8080/notes/"
))
...
...
@@ -40,6 +46,7 @@ class HttpOperations {
.
PUT
(
HttpRequest
.
BodyPublishers
.
ofString
(
jsonNote
))
.
build
()
val
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
())
return
response
.
body
()
}
...
...
@@ -50,6 +57,7 @@ class HttpOperations {
.
DELETE
()
.
build
()
val
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
())
return
response
.
body
()
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment