Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20240528-BJava
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20240528-BJava
Commits
9fa74dad
Commit
9fa74dad
authored
Jun 14, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parametry - ostatnie zmiany
parent
77d3b218
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
Kalkulator.java
PC27-RestSerwer/src/main/java/hello/Kalkulator.java
+34
-0
Parametry.java
PC27-RestSerwer/src/main/java/hello/Parametry.java
+5
-7
No files found.
PC27-RestSerwer/src/main/java/hello/Kalkulator.java
0 → 100644
View file @
9fa74dad
package
hello
;
import
jakarta.ws.rs.GET
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
@Path
(
"/calc"
)
public
class
Kalkulator
{
@GET
@Path
(
"/{x}+{y}"
)
public
long
dodaj
(
@PathParam
(
"x"
)
long
a
,
@PathParam
(
"y"
)
long
b
)
{
return
a
+
b
;
}
@GET
@Path
(
"/{x}-{y}"
)
public
long
odejmij
(
@PathParam
(
"x"
)
long
a
,
@PathParam
(
"y"
)
long
b
)
{
return
a
-
b
;
}
@GET
@Path
(
"/{x}*{y}"
)
public
long
pomnoz
(
@PathParam
(
"x"
)
long
a
,
@PathParam
(
"y"
)
long
b
)
{
return
a
*
b
;
}
@GET
@Path
(
"/{x}/{y}"
)
public
long
podziel
(
@PathParam
(
"x"
)
long
a
,
@PathParam
(
"y"
)
long
b
)
{
return
a
/
b
;
}
}
PC27-RestSerwer/src/main/java/hello/Parametry.java
View file @
9fa74dad
...
...
@@ -43,22 +43,21 @@ public class Parametry {
+
"\nTablica: "
+
Arrays
.
toString
(
t
);
}
// /api/parametry/path/Ala/123/98765qwerty@res-zta
// /api/parametry/path/Ala/123/98765qwerty
// przykład realnego użycia: /products/{id}
@GET
@Path
(
"/path/{a}/{b}/{cyfry:\\d+}{litery:
\\w+}{reszta
}"
)
@Path
(
"/path/{a}/{b}/{cyfry:\\d+}{litery:
[A-Za-z]*
}"
)
public
String
pathParam
(
@PathParam
(
"a"
)
String
a
,
@PathParam
(
"b"
)
String
b
,
@PathParam
(
"cyfry"
)
String
cyfry
,
@PathParam
(
"litery"
)
String
litery
,
@PathParam
(
"reszta"
)
String
reszta
@PathParam
(
"litery"
)
String
litery
)
{
return
"Parametr a = "
+
a
+
"\nParametr b = "
+
b
+
"\nCyfry: "
+
cyfry
+
"\nLitery: "
+
litery
+
"\nReszta: "
+
reszta
;
+
"\nLitery: "
+
litery
;
}
@GET
...
...
@@ -67,7 +66,6 @@ public class Parametry {
@HeaderParam
(
"accept"
)
String
accept
,
@HeaderParam
(
"user-agent"
)
String
agent
)
{
return
"Accept: "
+
accept
+
"\nUser-Agent: "
+
agent
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment