Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04binôme2A
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Monitor
Incidents
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
Gabrielle Van De Vijver
IA04binôme2A
Commits
462752e4
Commit
462752e4
authored
1 year ago
by
Balthazar Wilson
Browse files
Options
Downloads
Patches
Plain Diff
WIP: vote
parent
078e1c4b
No related branches found
Branches containing commit
No related tags found
1 merge request
!8
implémentation des votants par Balthazar
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
agt/ballotagent/ballotagent.go
+2
-2
2 additions, 2 deletions
agt/ballotagent/ballotagent.go
agt/ballotagent/vote.go
+29
-0
29 additions, 0 deletions
agt/ballotagent/vote.go
with
31 additions
and
2 deletions
agt/ballotagent/ballotagent.go
+
2
−
2
View file @
462752e4
...
...
@@ -34,7 +34,7 @@ func (rsa *BallotServerAgent) checkMethod(method string, w http.ResponseWriter,
return
true
}
func
(
*
BallotServerAgent
)
decodeRequest
(
r
*
http
.
Request
)
(
req
rad
.
BallotRequest
,
err
error
)
{
func
(
*
BallotServerAgent
)
decodeRequest
[
R
any
]
(
r
*
http
.
Request
)
(
req
rad
.
BallotRequest
,
err
error
)
{
buf
:=
new
(
bytes
.
Buffer
)
buf
.
ReadFrom
(
r
.
Body
)
err
=
json
.
Unmarshal
(
buf
.
Bytes
(),
&
req
)
...
...
@@ -57,7 +57,7 @@ func (rsa *BallotServerAgent) Start() {
// création du multiplexer
mux
:=
http
.
NewServeMux
()
mux
.
HandleFunc
(
"/new_ballot"
,
rsa
.
createBallot
)
mux
.
HandleFunc
(
"/vote"
,
rsa
.
doReqcount
)
mux
.
HandleFunc
(
"/vote"
,
rsa
.
receiveVote
)
mux
.
HandleFunc
(
"/result"
,
rsa
.
doReqcount
)
rsa
.
ballots
=
make
(
map
[
rad
.
Ballot
]
BallotInfo
)
...
...
This diff is collapsed.
Click to expand it.
agt/ballotagent/vote.go
0 → 100644
+
29
−
0
View file @
462752e4
package
ballotagent
import
(
"fmt"
"net/http"
)
func
(
rsa
*
BallotServerAgent
)
receiveVote
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// mise à jour du nombre de requêtes
rsa
.
Lock
()
defer
rsa
.
Unlock
()
rsa
.
reqCount
++
// vérification de la méthode de la requête
if
!
rsa
.
checkMethod
(
"POST"
,
w
,
r
)
{
return
}
// décodage de la requête
req
,
err
:=
rsa
.
decodeRequest
(
r
)
if
err
!=
nil
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
fmt
.
Fprint
(
w
,
err
.
Error
())
return
}
// recupération des infos
scrutin
:=
req
.
}
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