-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from xxxsen/xxxsen/feature/rewrite_plugin_api
Xxxsen/feature/rewrite plugin api
- Loading branch information
Showing
30 changed files
with
440 additions
and
301 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package envflag | ||
|
||
import ( | ||
"github.com/kelseyhightower/envconfig" | ||
) | ||
|
||
var defaultInst = &EnvFlag{} | ||
|
||
type EnvFlag struct { | ||
EnableSearchMetaCache bool `envconfig:"enable_search_meta_cache" default:"true"` | ||
EnableLinkMode bool `envconfig:"enable_link_mode"` | ||
} | ||
|
||
func GetFlag() *EnvFlag { | ||
return defaultInst | ||
} | ||
|
||
func Init() error { | ||
fg := &EnvFlag{} | ||
if err := envconfig.Process("exec_flag", fg); err != nil { | ||
return err | ||
} | ||
defaultInst = fg | ||
return nil | ||
} | ||
|
||
func IsEnableSearchMetaCache() bool { | ||
return GetFlag().EnableSearchMetaCache | ||
} | ||
|
||
func IsEnableLinkMode() bool { | ||
return GetFlag().EnableLinkMode | ||
} |
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
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,21 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"yamdc/model" | ||
"yamdc/number" | ||
) | ||
|
||
type HTTPInvoker func(ctx context.Context, req *http.Request) (*http.Response, error) | ||
|
||
type IPlugin interface { | ||
OnHTTPClientInit() HTTPInvoker | ||
OnPrecheckRequest(ctx context.Context, number *number.Number) (bool, error) | ||
OnMakeHTTPRequest(ctx context.Context, number *number.Number) (*http.Request, error) | ||
OnDecorateRequest(ctx context.Context, req *http.Request) error | ||
OnHandleHTTPRequest(ctx context.Context, invoker HTTPInvoker, req *http.Request) (*http.Response, error) | ||
OnPrecheckResponse(ctx context.Context, req *http.Request, rsp *http.Response) (bool, error) | ||
OnDecodeHTTPData(ctx context.Context, data []byte) (*model.AvMeta, bool, error) | ||
OnDecorateMediaRequest(ctx context.Context, req *http.Request) error | ||
} |
Oops, something went wrong.