Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

Commit

Permalink
新增api接口
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Feb 4, 2017
1 parent e78ecba commit aed6c20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import "github.com/lunny/tango"

// APIAction 提供了API访问的能力
type APIAction struct {
tango.Json
}

func (a *APIAction) Get() interface{} {
news, err := getNews()
if err != nil {
return err
}

return news
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ func main() {
},
}))
t.Get("/", new(HomeAction))
t.Get("/api/v1/news", new(APIAction))
t.Run(":8980")
}

0 comments on commit aed6c20

Please sign in to comment.