This repository was archived by the owner on May 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ func SetupCache() {
1414 Password : conf .Redis .Password ,
1515 DB : conf .Redis .DB ,
1616 })
17- pong , err := client .Ping (context .Background ()).Result ()
17+ _ , err := client .Ping (context .Background ()).Result ()
1818 if err != nil {
1919 logger .Fatal ("Failed to connect to Redis server: " , err )
2020 } else {
Original file line number Diff line number Diff line change 11package main
22
3- import (
4- "fmt"
5- "github.com/kataras/iris/v12"
6- )
7-
83func main () {
9- app := iris .Default ()
10- {
11- app .Get ("/user/{username:string}" , UserAPI )
12- app .Get ("/repo/{username:string}/{repo:string}" , RepoAPI )
13- }
14-
154 SetupLogger ()
165 ReadConfig ()
176 ReadToken ()
187 SetupCache ()
19-
20- app .Listen (fmt .Sprintf (":%d" , conf .Server .Port ))
21- }
22-
23- func UserAPI (ctx iris.Context ) {
24- username := ctx .Params ().Get ("username" )
25- data , err , code := AnalysisUser (username )
26- if err != nil {
27- ThrowError (ctx , err .Error (), code )
28- } else {
29- ctx .JSON (data )
30- }
31- }
32-
33- func RepoAPI (ctx iris.Context ) {
34- username , repo := ctx .Params ().Get ("username" ), ctx .Params ().Get ("repo" )
35- data , err , code := AnalysisRepo (username , repo )
36- if err != nil {
37- ThrowError (ctx , err .Error (), code )
38- } else {
39- ctx .JSON (data )
40- }
8+ RunServer ()
419}
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "github.com/kataras/iris/v12"
6+ )
7+
8+ func RunServer () {
9+ app := iris .Default ()
10+ {
11+ app .Get ("/user/{username:string}" , UserAPI )
12+ app .Get ("/repo/{username:string}/{repo:string}" , RepoAPI )
13+ }
14+ app .Listen (fmt .Sprintf (":%d" , conf .Server .Port ))
15+ }
16+
17+ func UserAPI (ctx iris.Context ) {
18+ username := ctx .Params ().Get ("username" )
19+ data , err , code := AnalysisUser (username )
20+ if err != nil {
21+ ThrowError (ctx , err .Error (), code )
22+ } else {
23+ ctx .JSON (data )
24+ }
25+ }
26+
27+ func RepoAPI (ctx iris.Context ) {
28+ username , repo := ctx .Params ().Get ("username" ), ctx .Params ().Get ("repo" )
29+ data , err , code := AnalysisRepo (username , repo )
30+ if err != nil {
31+ ThrowError (ctx , err .Error (), code )
32+ } else {
33+ ctx .JSON (data )
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments