jkframe

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2022 License: MIT

README

jkframe

jkframe Go Report Card go-mod license

English | 中文文档

jkstack golang basic framework

modules

  • api: http handler interface, includes arguments parser and response reply
  • l2cache: cache with memory and disk, when write data size more than values seted, the cache data will write to the disk
  • kvconf: supported configure file with key=value
  • yaml: supported yaml file parse, added #include keyword to include another yaml file
  • daemon: daemon process supported, supported change run user in child process, supported restart when child process exited
  • logging: log library, supported log level of each format, supported log rotate by date and log file size
  • mysqlschema: mysql table schema and initialize data management tools, supported table schema version and initialize data version
  • utils: common function, like UUID, assert, get callstack
  • prometheus: prometheus library(developing)

usage

go get -u github.com/jkstack/jkframe

Directories

Path Synopsis
http handler library, Context is the main struct of this library default response data format like below {"code": 0, "payload": ...} parse request arguments: Context.X(type): means the argument by name is required, if not passed the argument it will panic with MissingParam error, if passed argument type is wrong it will panic with BadParam error Context.O(type): means the argument by name is optional, if not passed the argument it will return default value, if passed argument type is wrong it will return the zero value of its type response data: Context.OK: the api handler processed ok and response data like below {"code": 0, "payload": ...} Context.ERR: the api handler processed failed and response data like below {"code": code, "msg": error message} Context.Body: response data in byte slice Context.BodyFrom: response data from io.Reader http response: Context.HTTPNotFound: response http_code=404 Context.HTTPServiceUnavailable: response http_code=503 Context.HTTPTimeout: response http_code=408 Context.HTTPConflict: response http_code=409 Context.HTTPForbidden: response http_code=403 common errors: Context.NotFound: panic with NotFound error Context.Timeout: panic with Timeout error
http handler library, Context is the main struct of this library default response data format like below {"code": 0, "payload": ...} parse request arguments: Context.X(type): means the argument by name is required, if not passed the argument it will panic with MissingParam error, if passed argument type is wrong it will panic with BadParam error Context.O(type): means the argument by name is optional, if not passed the argument it will return default value, if passed argument type is wrong it will return the zero value of its type response data: Context.OK: the api handler processed ok and response data like below {"code": 0, "payload": ...} Context.ERR: the api handler processed failed and response data like below {"code": code, "msg": error message} Context.Body: response data in byte slice Context.BodyFrom: response data from io.Reader http response: Context.HTTPNotFound: response http_code=404 Context.HTTPServiceUnavailable: response http_code=503 Context.HTTPTimeout: response http_code=408 Context.HTTPConflict: response http_code=409 Context.HTTPForbidden: response http_code=403 common errors: Context.NotFound: panic with NotFound error Context.Timeout: panic with Timeout error
cache
conf
kvconf/example command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL