-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in phstsai/VX-86 (pull request #6)
DEV VX-86: RESTful API for Creating Network Approved-by: Hung-Wei Chiu <[email protected]> Approved-by: Yo-An Lin <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,148 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"redis": { | ||
"host": "localhost", | ||
"port": 6379, | ||
"public": { | ||
"host": "localhost" | ||
} | ||
}, | ||
"mongo": { | ||
"url": "mongodb://localhost:31717/vortex_test" | ||
}, | ||
"influxdb": { | ||
"url": "http://localhost:8086", | ||
"database": "lisa" | ||
}, | ||
"logger": { | ||
"dir": "./logs", | ||
"level": "debug", | ||
"maxAge": "720h", | ||
"suffixPattern": ".%Y%m%d", | ||
"linkName": "access_log" | ||
}, | ||
"app": { | ||
"brand": { | ||
"name": "Vortex", | ||
"identifier": "vortex", | ||
"companyName": "Linker Networks Inc." | ||
}, | ||
"dbVersion": "v1.0.0", | ||
"version": "local", | ||
"logFileName": "access_log" | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package entity | ||
|
||
import ( | ||
"time" | ||
|
||
"gopkg.in/mgo.v2/bson" | ||
) | ||
|
||
const ( | ||
NetworkCollectionName string = "networks" | ||
) | ||
|
||
type PhysicalPort struct { | ||
Name string `bson:"name" json:"name"` | ||
MTU int `bson:"maximumTransmissionUnit" MTC:"maximumTransmissionUnit"` | ||
VlanTags []int `bson:"vlanTag" MTC:"vlanTag"` | ||
} | ||
|
||
type Network struct { | ||
ID bson.ObjectId `bson:"_id,omitempty" json:"id"` | ||
DisplayName string `bson:"displayName" json:"displayName"` | ||
BridgeName string `bson:"bridgeName" json:"bridgeName"` | ||
BridgeType string `bson:"bridgeType" json:"bridgeType"` | ||
Node string `bson:"node" json:"node"` | ||
PhysicalPorts []PhysicalPort `bson:"physicalPorts" json:"physicalPorts"` | ||
CreatedAt *time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"` | ||
} | ||
|
||
//GetCollection - get model mongo collection name. | ||
func (m Network) GetCollection() string { | ||
return NetworkCollectionName | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package http | ||
|
||
import ( | ||
"net/http" | ||
|
||
"bitbucket.org/linkernetworks/vortex/src/serviceprovider" | ||
"bitbucket.org/linkernetworks/vortex/src/web" | ||
"github.com/emicklei/go-restful" | ||
"github.com/linkernetworks/logger" | ||
) | ||
|
||
type NativeContextHandler func(*web.NativeContext) | ||
|
||
// CompositeServiceProvider apply mongo client to HandlerFunc | ||
func CompositeServiceHandler(sp *serviceprovider.Container, handler NativeContextHandler) http.HandlerFunc { | ||
return func(resp http.ResponseWriter, req *http.Request) { | ||
logger.Infoln(req.Method, req.URL) | ||
ctx := web.NativeContext{sp, req, resp} | ||
handler(&ctx) | ||
} | ||
} | ||
|
||
type RESTfulContextHandler func(*web.Context) | ||
|
||
func RESTfulServiceHandler(sp *serviceprovider.Container, handler RESTfulContextHandler) restful.RouteFunction { | ||
return func(req *restful.Request, resp *restful.Response) { | ||
ctx := web.Context{sp, req, resp} | ||
handler(&ctx) | ||
} | ||
} |
Oops, something went wrong.