favclip / ucon Goto Github PK
View Code? Open in Web Editor NEWucon is a web application framework, which is pluggable by Middleware and Plugin. ucon is the name of turmeric in Japanese. ucon knocks down any alcohol. :)
License: MIT License
ucon is a web application framework, which is pluggable by Middleware and Plugin. ucon is the name of turmeric in Japanese. ucon knocks down any alcohol. :)
License: MIT License
Currently, ucon Swagger Plugin scan all handlers added to ucon, then the handler show in swagger.json.
In some case, we want to ignore handlers in swagger.json like admin view.
We need an option for ignoring swagger scan like below.
swPlugin := swagger.NewPlugin(&swagger.Options{
Object: &swagger.Object{
Info: &swagger.Info{
Title: "Todo list",
Version: "v1",
},
Schemes: []string{"http"},
},
DefinitionNameModifier: func(refT reflect.Type, defName string) string {
if strings.HasSuffix(defName, "JSON") {
return defName[:len(defName)-4]
}
return defName
},
IgnoreRoute: func(rd *ucon.RouteDefinition) bool {
return strings.HasPrefix(rd.PathTemplate.PathTemplate, "/admin")
},
})
ucon.Plugin(swPlugin)
Since the default, https is set as the schema, it can not distinguish that localhost In http, server in https.
{
"swagger": "2.0",
"info": {
"title": "Cloud Platform Training",
"version": "v1"
},
"schemes": [
"https"
]
}
I want to change swagger.json url.
if we can change it, we can have multiple swagger definitions with #27 like below.
publicSwPlugin := swagger.NewPlugin(&swagger.Options{
// SwaggerJSONPath: "/api/swagger.json", this is default
Object: &swagger.Object{
Info: &swagger.Info{
Title: "Todo list",
Version: "v1",
},
Schemes: []string{"http"},
},
DefinitionNameModifier: func(refT reflect.Type, defName string) string {
if strings.HasSuffix(defName, "JSON") {
return defName[:len(defName)-4]
}
return defName
},
IgnoreRoute: func(rd *ucon.RouteDefinition) bool {
return strings.HasPrefix(rd.PathTemplate.PathTemplate, "/admin")
},
})
ucon.Plugin(publicSwPlugin)
adminSwPlugin := swagger.NewPlugin(&swagger.Options{
SwaggerJSONPath: "/admin/api/swagger.json",
Object: &swagger.Object{
Info: &swagger.Info{
Title: "Todo list",
Version: "v1",
},
Schemes: []string{"http"},
},
DefinitionNameModifier: func(refT reflect.Type, defName string) string {
if strings.HasSuffix(defName, "JSON") {
return defName[:len(defName)-4]
}
return defName
},
IgnoreRoute: func(rd *ucon.RouteDefinition) bool {
return !strings.HasPrefix(rd.PathTemplate.PathTemplate, "/admin")
},
})
ucon.Plugin(adminSwPlugin)
I want to return 201 when a successful HTTP POST.
Is I How can I achieve it with ucon?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.