This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
type Tag struct { | |
Model | |
Name string `json:"name"` | |
CreatedBy string `json:"created_by"` | |
ModifiedBy string `json:"modified_by"` | |
State int `json:"state"` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gavinzhou/hello-gin/pkg/setting" | |
"github.com/gin-gonic/gin" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import ( | |
"fmt" | |
"log" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/postgres" | |
"github.com/gavinzhou/hello-gin/pkg/setting" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import ( | |
"github.com/Unknwon/com" | |
"github.com/gin-gonic/gin" | |
"github.com/gavinzhou/hello-gin/pkg/setting" | |
) | |
func GetPage(c *gin.Context) int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package e | |
var MsgFlags = map[int]string{ | |
SUCCESS: "ok", | |
ERROR: "fail", | |
INVALID_PARAMS: "invalid params", | |
ERROR_EXIST_TAG: "tag is exist", | |
ERROR_NOT_EXIST_TAG: "tag is not exist", | |
ERROR_NOT_EXIST_ARTICLE: "article is not exist", | |
ERROR_AUTH_CHECK_TOKEN_FAIL: "token check is fail", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package e | |
const ( | |
SUCCESS = 200 | |
ERROR = 500 | |
INVALID_PARAMS = 400 | |
ERROR_EXIST_TAG = 10001 | |
ERROR_NOT_EXIST_TAG = 10002 | |
ERROR_NOT_EXIST_ARTICLE = 10003 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package setting | |
import ( | |
"time" | |
"github.com/kelseyhightower/envconfig" | |
) | |
type DBConfig struct { | |
DBHost string `envconfig:"DBHost"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -s localhost:2379/v2/keys/registry/example.com/databases/default | jq . | |
{ | |
"action": "get", | |
"node": { | |
"key": "/registry/example.com/databases/default", | |
"dir": true, | |
"nodes": [ | |
{ | |
"key": "/registry/example.com/databases/default/wordpress", | |
"value": "{\"apiVersion\":\"example.com/v1\",\"kind\":\"Database\",\"metadata\":{\"clusterName\":\"\",\"creationTimestamp\":\"2017-08-09T14:53:40Z\",\"deletionGracePeriodSeconds\":null,\"deletionTimestamp\":null,\"name\":\"wordpress\",\"namespace\":\"default\",\"selfLink\":\"\",\"uid\":\"8837f788-7d12-11e7-9d28-080027390640\"},\"spec\":{\"encoding\":\"unicode\",\"password\":\"secret\",\"user\":\"wp\"}}\n", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ http 127.0.0.1:8001/apis/example.com/v1/namespaces/default/databases | |
HTTP/1.1 200 OK | |
Content-Length: 593 | |
Content-Type: application/json | |
Date: Wed, 09 Aug 2017 09:38:49 GMT | |
{ | |
"apiVersion": "example.com/v1", | |
"items": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat wordpress-database.yaml | |
apiVersion: example.com/v1 | |
kind: Database | |
metadata: | |
name: wordpress | |
spec: | |
user: wp | |
password: secret | |
encoding: unicode |