-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
1,826 additions
and
4,653 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,5 @@ tmp.out | |
# GoLand project files | ||
.idea/ | ||
*.iml | ||
|
||
/mir |
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,58 @@ | ||
// Copyright 2019 Michael Li <alimy@gility.net>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package core | ||
|
||
var ( | ||
// Generators generators list | ||
Generators = make(map[string]Generator, 4) | ||
|
||
// DefParser default parser | ||
DefParser Parser | ||
) | ||
|
||
// Generator list | ||
var ( | ||
EngineGin = "gin" | ||
EngineChi = "chi" | ||
EngineMux = "mux" | ||
EngineHttpRouter = "httprouter" | ||
) | ||
|
||
// GenOpts generator options | ||
type GenOpts struct { | ||
Name string | ||
OutPath string | ||
} | ||
|
||
// TagMir mir tag's info | ||
type TagMir struct { | ||
// TODO | ||
} | ||
|
||
// Parser parse entries | ||
type Parser interface { | ||
Name() string | ||
Parse(entries []interface{}) ([]*TagMir, error) | ||
} | ||
|
||
// Generator generate interface code for engine | ||
type Generator interface { | ||
Name() string | ||
Generate([]*TagMir, *GenOpts) error | ||
} | ||
|
||
// Register generator | ||
func Register(gs ...Generator) { | ||
for _, g := range gs { | ||
if g != nil && g.Name() != "" { | ||
Generators[g.Name()] = g | ||
} | ||
} | ||
} | ||
|
||
// setDefParser set default parser | ||
func SetDefParser(p Parser) { | ||
DefParser = p | ||
} |
Oops, something went wrong.