Request routing in Arnica Golang script

September 23, 2019 by Igor Lozhkin
In Arnica Golang script, the route is registered using the following function in server package:
func AddRoute(method string, route string, functionName RouteHandler)
AddRoute registers RouteHandler function to process the route. Example of the route is:
/path1/path2/{{var1}}/path3/{{var2}}/*/path4/

Route must start with slash "/". Empty route is not allowed, route "/" should be used as the default route.


Route path variable names can be enclosed in {{ }} delimiters.

 

Wildcard route path components are supported by using an asterisk. Asterisk cannot be combined with other symbols within the same route path component.

 

Routes with invalid path variable references, or invalid methods, or empty routes, or nil functions are not registered.


Routes are registered for a specified http method. Method could be one of the following: 

  • get
  • head
  • post
  • put
  • delete
  • connect
  • options
  • trace
  • patch

Special method "any" allows any of the above-mentioned standard methods against the specified route.

 

If both standard and "any" methods were defined for the same route, standard method is given priority.

 

If method is empty, special method "any" is assumed.

  

Methods and routes in Arnica are case insensitive. RouteHandler function name and route path variables are case sensitive.