Skip to content
This repository was archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
renomeando package e bind
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonata-menezes committed May 3, 2017
1 parent 25348b8 commit 8c732a9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cache.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kartola
package kartolafc

import (
"github.com/jhonata-menezes/kartola/api"
"github.com/jhonata-menezes/kartolafc-backend/api"
"time"
)

Expand Down
19 changes: 19 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/spf13/cobra"
"os"
)

var ServerBind string

func init() {
cmd := cobra.Command{}
cmd.Flags().StringVarP(&ServerBind, "bind", "b", "0.0.0.0:5015", "bind de interface ip:porta")
//"Kartola FC é um wrapper da API do cartolafc"

if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}

9 changes: 6 additions & 3 deletions controller.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package kartola
package kartolafc

import (
"github.com/jhonata-menezes/kartola/api"
"github.com/jhonata-menezes/kartolafc-backend/api"
"net/http"
"github.com/pressly/chi"
"strconv"
"github.com/pressly/chi/render"
"encoding/json"
)

func GetHome(response http.ResponseWriter, request *http.Request) {
responseDefault(response)
render.JSON(response, request, []byte("{ \"status\":\"Birll\"}"))
var out map[string]string
json.Unmarshal([]byte("{ \"status\":\"Birll\"}"), &out)
render.JSON(response, request, out)
}

func GetStatus(response http.ResponseWriter, request *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion json_build.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kartola
package kartolafc

import (
"encoding/json"
Expand Down
17 changes: 12 additions & 5 deletions main/kartola.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package main

import (
"github.com/pressly/chi"
"github.com/jhonata-menezes/kartola"
kartolafc "github.com/jhonata-menezes/kartolafc-backend"
"net/http"
"fmt"
"github.com/pressly/chi/middleware"
"github.com/pressly/chi/render"
"github.com/jhonata-menezes/kartolafc-backend/cmd"
"log"
)

func main(){
go kartola.UpdateCache()
func main() {

go kartolafc.UpdateCache()

router := chi.NewRouter()
router.Use(middleware.DefaultCompress)
Expand All @@ -20,7 +23,11 @@ func main(){
router.Use(middleware.RealIP)
router.Use(middleware.RequestID)

kartola.BuildRoutes(router)
kartolafc.BuildRoutes(router)
fmt.Println("Bora Cumpade.")
http.ListenAndServe("0.0.0.0:5015", router)
log.Println("listen", cmd.ServerBind)
err := http.ListenAndServe(cmd.ServerBind, router)
if err != nil {
panic(err)
}
}
2 changes: 1 addition & 1 deletion request.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kartola
package kartolafc

import (
"github.com/valyala/fasthttp"
Expand Down
2 changes: 1 addition & 1 deletion routes.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kartola
package kartolafc

import "github.com/pressly/chi"

Expand Down

0 comments on commit 8c732a9

Please sign in to comment.