rancher/norman

Name: norman

Owner: Rancher

Description: APIs on APIs on APIs

Created: 2017-10-16 02:23:47.0

Updated: 2018-05-18 15:27:28.0

Pushed: 2018-05-25 00:59:09.0

Homepage: null

Size: 4025

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Norman

An API framework for Building Rancher Style APIs backed by K8s CustomResources.

Building

make

Example

Refer to examples/

age main

rt (
"context"
"fmt"
"net/http"
"os"

"github.com/rancher/norman/generator"
"github.com/rancher/norman/server"
"github.com/rancher/norman/types"


 Foo struct {
types.Resource
Name     string `json:"name"`
Foo      string `json:"foo"`
SubThing Baz    `json:"subThing"`


 Baz struct {
Name string `json:"name"`


(
version = types.APIVersion{
    Version: "v1",
    Group:   "io.cattle.core.example",
    Path:    "/example/v1",
}

Schemas = types.NewSchemas()


 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)

License

Copyright (c) 2014-2017 Rancher Labs, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.