public AddProcessor ( PostRouteProcessor processor ) : void | ||
processor | PostRouteProcessor | |
return | void |
private void AddRoutes() { AllowCrossOrigin = true; _prefixRouteMapper = WebServer.Routes.Add(_routePrefix, HTTPMethod.OPTIONS, (Request, response) => { }, true); _prefixRouteMapper.AddProcessor(_accessControlProcessor); // meta route _metaRouteMapper = WebServer.Routes.Add(_routePrefix + WoopsaFormat.VerbMeta, HTTPMethod.GET, (request, response) => { HandleRequest(WoopsaVerb.Meta, request, response); }, true); _metaRouteMapper.AddProcessor(_accessControlProcessor); // read route _readRouteMapper = WebServer.Routes.Add(_routePrefix + WoopsaFormat.VerbRead, HTTPMethod.GET, (request, response) => { HandleRequest(WoopsaVerb.Read, request, response); }, true); _readRouteMapper.AddProcessor(_accessControlProcessor); // write route _writeRouteMapper = WebServer.Routes.Add(_routePrefix + WoopsaFormat.VerbWrite, HTTPMethod.POST, (request, response) => { HandleRequest(WoopsaVerb.Write, request, response); }, true); _writeRouteMapper.AddProcessor(_accessControlProcessor); // POST is used here instead of GET for two main reasons: // - The length of a GET query is limited in HTTP. There is no official limit but most // implementations have a 2-8 KB limit, which is not good when we want to do large // multi-requestsList, for example // - GET requestsList should not change the state of the server, as they can be triggered // by crawlers and such. Invoking a function will, in most cases, change the state of // the server. _invokeRouteMapper = WebServer.Routes.Add(_routePrefix + WoopsaFormat.VerbInvoke, HTTPMethod.POST, (request, response) => { HandleRequest(WoopsaVerb.Invoke, request, response); }, true); _invokeRouteMapper.AddProcessor(_accessControlProcessor); }