Documentation ¶
Index ¶
- Constants
- Variables
- func FileExists(file string) bool
- func ParseAndRun()
- type ClientConfig
- type HTTP_ACTION
- type HTTP_METHOD
- type HttpFileModel
- type HttpFileResolver
- type HttpFileType
- type HttpServer
- type JsonFileResolver
- type Route
- func (route Route) ServAppend(w http.ResponseWriter, r *http.Request, values url.Values)
- func (route Route) ServDelete(w http.ResponseWriter, r *http.Request, values url.Values)
- func (route Route) ServHTTP(w http.ResponseWriter, r *http.Request, values url.Values)
- func (route Route) ServRead(w http.ResponseWriter, r *http.Request, values url.Values)
- func (route Route) ServWrite(w http.ResponseWriter, r *http.Request, values url.Values)
- func (route Route) WriteResponse(w http.ResponseWriter, data any) bool
- type RouteInfo
- type RouteInfoMap
- type RouteMap
- type ServerConfig
- type YamlFileResolver
Constants ¶
View Source
const ( KEY_HTTP_PORT = "port" KEY_DYNAMIC_ROUTE = "dynamic_route" KEY_HTTP_ROOT = "db_root" KEY_CONSUL_API_BASE = "consul_api_base" KEY_CONSUL_SERVICE_NAME = "consul_service_name" KEY_CONSUL_SERVICE_HOST = "consul_service_host" DEFAULT_HTTP_PORT = 8080 DEFAULT_DYNAMIC_POST = true DEFAULT_HTTP_ROOT = "http-server-root" CONTENT_TYPE_CHARSET = "charset=" CONTENT_TYPE_BOUNDARY = "boundary=" MIME_TYPE_JSON = "application/json" MIME_TYPE_YAML = "application/yaml" DEFAULT_FILE_EXT = ".json" )
Variables ¶
View Source
var ( HTTP_METHOD_GET = enum.InitEnum[HTTP_METHOD]("GET", "GET") HTTP_METHOD_POST = enum.InitEnum[HTTP_METHOD]("POST", "POST") HTTP_METHOD_PUT = enum.InitEnum[HTTP_METHOD]("PUT", "PUT") HTTP_METHOD_DELETE = enum.InitEnum[HTTP_METHOD]("DELETE", "DELETE") HTTP_ACTION_APPEND = enum.InitEnum[HTTP_ACTION]("a", "append") HTTP_ACTION_READ = enum.InitEnum[HTTP_ACTION]("r", "read") HTTP_ACTION_WRITE = enum.InitEnum[HTTP_ACTION]("w", "write") HTTP_ACTION_DELETE = enum.InitEnum[HTTP_ACTION]("d", "delete") DEFAULT_RESPONSE = map[string]bool{"success": true} FILE_EXT_JSON = []string{"json"} FILE_EXT_YAML = []string{"yaml", "yml"} JsonResolver = JsonFileResolver{} YamlResolver = YamlFileResolver{} MimeTypeMap = make(map[string]HttpFileType) FileExtMap = make(map[string]HttpFileType) )
Functions ¶
func FileExists ¶
func ParseAndRun ¶
func ParseAndRun()
Types ¶
type ClientConfig ¶
type ClientConfig interface {
Start()
}
type HTTP_ACTION ¶
type HTTP_METHOD ¶
type HttpFileModel ¶
type HttpFileResolver ¶
type HttpFileType ¶
type HttpFileType struct { MimeType string FileExts []string DefaultFileExt string Resolver HttpFileResolver }
type HttpServer ¶
type HttpServer struct { Port int16 DynamicRoute bool DBRoot string ConsulApiBase string ConsulServiceName string ConsulServiceHost string StaticRoutes RouteMap }
func (*HttpServer) Listen ¶
func (server *HttpServer) Listen()
func (*HttpServer) ServeHTTP ¶
func (server *HttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type JsonFileResolver ¶
type JsonFileResolver struct{}
func (JsonFileResolver) ContentType ¶
func (resolver JsonFileResolver) ContentType() string
type Route ¶
type Route struct { Path string Method *HTTP_METHOD Action *HTTP_ACTION File string Single bool Id []string Fields []string UniqueNotList bool Resolver HttpFileResolver }
func (Route) ServAppend ¶
func (Route) ServDelete ¶
func (Route) WriteResponse ¶
func (route Route) WriteResponse(w http.ResponseWriter, data any) bool
type RouteInfo ¶
type RouteInfo struct { Path string `toml:"path,omitempty"` Method string `toml:"method,omitempty"` Action string `toml:"action,omitempty"` Format string `toml:"format,omitempty"` File string `toml:"file,omitempty"` Single bool `toml:"single,omitempty"` Id []string `toml:"id,omitempty"` Fields []string `toml:"fields,omitempty"` UniqueNotList bool `toml:"unique_not_list,omitempty"` }
type RouteInfoMap ¶
type ServerConfig ¶
type ServerConfig interface {
Listen()
}
type YamlFileResolver ¶
type YamlFileResolver struct{}
func (YamlFileResolver) ContentType ¶
func (resolver YamlFileResolver) ContentType() string
Click to show internal directories.
Click to hide internal directories.