mirror of
https://github.com/rancher/norman.git
synced 2025-08-01 07:21:07 +00:00
Update readme to refer to go-skel
This commit is contained in:
parent
6c7654a69f
commit
aea43f15fd
59
README.md
59
README.md
@ -1,66 +1,11 @@
|
||||
Norman
|
||||
========
|
||||
|
||||
An API framework for Building [Rancher Style APIs](https://github.com/rancher/api-spec/) backed by K8s CustomResources.
|
||||
|
||||
## Building
|
||||
|
||||
`make`
|
||||
An API framework for Building [Rancher Style APIs](https://github.com/rancher/api-spec/) backed by K8s CustomResources and their controllers.
|
||||
|
||||
## Example
|
||||
|
||||
Refer to `examples/`
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rancher/norman/generator"
|
||||
"github.com/rancher/norman/server"
|
||||
"github.com/rancher/norman/types"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
types.Resource
|
||||
Name string `json:"name"`
|
||||
Foo string `json:"foo"`
|
||||
SubThing Baz `json:"subThing"`
|
||||
}
|
||||
|
||||
type Baz struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
var (
|
||||
version = types.APIVersion{
|
||||
Version: "v1",
|
||||
Group: "io.cattle.core.example",
|
||||
Path: "/example/v1",
|
||||
}
|
||||
|
||||
Schemas = types.NewSchemas()
|
||||
)
|
||||
|
||||
func main() {
|
||||
if _, err := Schemas.Import(&version, Foo{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
server, err := server.NewAPIServer(context.Background(), os.Getenv("KUBECONFIG"), Schemas)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("Listening on 0.0.0.0:1234")
|
||||
http.ListenAndServe("0.0.0.0:1234", server)
|
||||
}
|
||||
```
|
||||
|
||||
Refer to https://github.com/rancher/go-skel for skeleton norman controller projects
|
||||
|
||||
## License
|
||||
Copyright (c) 2014-2017 [Rancher Labs, Inc.](http://rancher.com)
|
||||
|
Loading…
Reference in New Issue
Block a user