Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MyAktion Go-ss2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
go-exercises
MyAktion Go-ss2023
Commits
25eef452
Commit
25eef452
authored
1 year ago
by
Martin Schmollinger
Browse files
Options
Downloads
Patches
Plain Diff
Added health service
parent
1d421a1e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/myaktion/go.mod
+2
-0
2 additions, 0 deletions
src/myaktion/go.mod
src/myaktion/go.sum
+2
-0
2 additions, 0 deletions
src/myaktion/go.sum
src/myaktion/handler/health.go
+11
-0
11 additions, 0 deletions
src/myaktion/handler/health.go
src/myaktion/main.go
+9
-24
9 additions, 24 deletions
src/myaktion/main.go
with
24 additions
and
24 deletions
src/myaktion/go.mod
+
2
−
0
View file @
25eef452
module gitlab.reutlingen-university.de/go-exercises/myaktion-go/src/myaktion
go 1.20
require github.com/gorilla/mux v1.8.0
This diff is collapsed.
Click to expand it.
src/myaktion/go.sum
0 → 100644
+
2
−
0
View file @
25eef452
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
This diff is collapsed.
Click to expand it.
src/myaktion/handler/health.go
0 → 100644
+
11
−
0
View file @
25eef452
package
handler
import
(
"io"
"net/http"
)
func
Health
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
io
.
WriteString
(
w
,
`{"alive": true}`
)
}
This diff is collapsed.
Click to expand it.
src/myaktion/main.go
+
9
−
24
View file @
25eef452
...
...
@@ -2,33 +2,18 @@ package main
import
(
"fmt"
"log"
"net/http"
"gitlab.reutlingen-university.de/go-exercises/myaktion-go/src/myaktion/model"
"github.com/gorilla/mux"
"gitlab.reutlingen-university.de/go-exercises/myaktion-go/src/myaktion/handler"
)
func
main
()
{
c
:=
model
.
Campaign
{
Name
:
"Kinder helfen"
,
OrganizerName
:
"Hans Schmidt"
,
TargetAmount
:
10000.0
,
DonationMinimum
:
10.0
,
Account
:
model
.
Account
{
Name
:
"Kinder helfen"
,
BankName
:
"Raiffeisen"
,
Number
:
"1234567890"
,
},
fmt
.
Println
(
"Starting MyAktion API server"
)
router
:=
mux
.
NewRouter
()
router
.
HandleFunc
(
"/health"
,
handler
.
Health
)
.
Methods
(
"GET"
)
if
err
:=
http
.
ListenAndServe
(
":8000"
,
router
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
c
.
Donations
=
append
(
c
.
Donations
,
model
.
Donation
{
Amount
:
100.0
,
DonorName
:
"Hans Muster"
,
ReceiptRequested
:
true
,
Status
:
model
.
IN_PROCESS
,
Account
:
model
.
Account
{
Name
:
"Hans Muster"
,
BankName
:
"Raiffeisen"
,
Number
:
"1234567890"
,
},
})
fmt
.
Printf
(
"%+v
\n
"
,
c
)
}
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