Skip to content
Snippets Groups Projects
Commit 8891beca authored by Flnal's avatar Flnal
Browse files

added new functions

parent e9fe4bf3
No related branches found
No related tags found
1 merge request!3Master
......@@ -2,4 +2,9 @@ module gitlab.reutlingen-university.de/albrecht/myaktion-go
go 1.20
require github.com/gorilla/mux v1.8.0
require (
github.com/gorilla/mux v1.8.0
github.com/sirupsen/logrus v1.9.0
)
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"log"
"net/http"
"os"
log "github.com/sirupsen/logrus"
"github.com/gorilla/mux"
"gitlab.reutlingen-university.de/albrecht/myaktion-go/src/myaktion/handler"
......@@ -10,10 +12,25 @@ import (
//"gitlab.reutlingen-university.de/albrecht/myaktion-go/src/myaktion/model"
func init() {
// init logger
log.SetFormatter(&log.TextFormatter{})
log.SetReportCaller(true)
level, err := log.ParseLevel(os.Getenv("LOG_LEVEL"))
if err != nil {
log.Info("Log level not specified, set default to: INFO")
log.SetLevel(log.InfoLevel)
return
}
log.SetLevel(level)
}
func main() {
log.Println("Starting My-Aktion API server")
router := mux.NewRouter()
router.HandleFunc("/health", handler.Health).Methods("GET")
router.HandleFunc("/campaign", handler.CreateCampaign).Methods("POST")
router.HandleFunc("/campaigns", handler.GetCampaigns).Methods("GET")
if err := http.ListenAndServe(":8000", router); err != nil {
log.Fatal(err)
}
......
package model
type Camaign struct {
type Campaign struct {
ID uint
Name string
OrganizerName string
TargetAmount float64
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment