Categorygithub.com/jph5396/MyAPI
modulepackage
0.1.2
Repository: https://github.com/jph5396/myapi.git
Documentation: pkg.go.dev

# README

MyAPI

A rest API framework aimed at isolating clientside errors in a single layer so developers can focus on cleaner code in other layers. WIP

# Functions

NewCustomRule creates a new custom rule that can be applied to properties.
NewEnumRule checks to see if all members provided are the same type, if so, it will return a valid EnumRule.
NewMiddleware returns a new middleware with the name and handler provided.
NewMyAPI creates a new MyAPI instance.
NewObjectProperty creates a new Object Property with the name provided and sets the slice.
NewProperty creates a property with a blank rule set.
NewPropertyGroup creates a PropertyGroup with no properties.
NewRegexRule accepts a string, confirms it's a valid regex pattern, and returns a rule if the pattern isvalid.
NewRoute takes in all neccesay parts of a route: path method and handler function.
NewSubRouter returns an empty subrouter with the provided prefix.
PropsFromType receives a reflect.Type of a struct and returns a propertygroup based of the field name and types of the struct useful for creating propertygroups that dont need any specific rules applied to them.

# Variables

Boolean boolean type variable.
Float float type variable.
Group PropertyGroup type variable.
Int int type variable.
String string type variable.

# Structs

CustomRule a rule type that allows users to define their own rule.
EnumRule checks to see if the property value is within a set of valid values.
Middleware represents a middleware function that uses http.Handler.
MyAPI ...
ObjectProperty represents a property that would be an object type in json instead of a basic type.
Property represents a single property in a request body.
PropertyGroup wrapper used to be sure property names are unique when applied to a route.
RegexRule checks to see if the propety value of a property matches the provided regex string.
Route describes a single route in the API.
SubRouter a grouping of routes.

# Interfaces

Props the interface that should represent a single property in a json object.
Rule Interface that defines the common interfaced that should be used when implementing a rule type all implemented rules can assume that the provided value is already an appropriate type, because the value will have been type checked before and invalid ones will not make it to the rule.

# Type aliases

Type used as a wrapper for reflect.Types in case I wish to change how types are defined in the package.