Created
December 9, 2014 20:34
-
-
Save aaronhurt/9494e5e7831fa927803e to your computer and use it in GitHub Desktop.
swagger and go-restful
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
// registration function | |
func (ml mlResource) register(container *restful.Container) { | |
// new service object | |
ws := new(restful.WebService) | |
// set the path | |
ws.Path(path.Join(ml.Config.Service.BasePath, "/rules")). | |
Doc("Get managed LAN rule set documents"). | |
Consumes(restful.MIME_JSON). | |
Produces(restful.MIME_JSON) | |
// list available configuration data | |
ws.Route(ws.GET("/list").To(ml.listRules). | |
Doc("List available rule sets"). | |
Operation("listConfig"). | |
Writes([]ruleListModel{})) | |
// get specific configuration data | |
ws.Route(ws.GET("/community").To(ml.getRules). | |
Doc("Get a rule set"). | |
Operation("getConfig"). | |
Param(ws.QueryParameter("id", "One or more comma separated community identifies."). | |
DataType("string").Required(true)). | |
Writes(ruleModel{})) | |
// add the service | |
container.Add(ws) | |
// second service | |
ws = new(restful.WebService) | |
// set the path | |
ws.Path(path.Join(ml.Config.Service.BasePath, "/lookup")). | |
Doc("Get managed LAN lookup documents"). | |
Consumes(restful.MIME_JSON). | |
Produces(restful.MIME_JSON) | |
// list available configuration data | |
ws.Route(ws.GET("/list").To(ml.listLookup). | |
Doc("List available lookup documents"). | |
Operation("listLookup"). | |
Writes([]lookupListModel{})) | |
// get specific configuration data | |
ws.Route(ws.GET("/config").To(ml.getLookup). | |
Doc("Get a lookup document"). | |
Operation("getLookup"). | |
Param(ws.QueryParameter("id", "One or more comma separated configuration file and path names from rancid."). | |
DataType("string").Required(true)). | |
Writes(lookupModel{})) | |
// add the service | |
container.Add(ws) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment