public ResourceProviderService(INAServerContext serverContext) { ServerContext = serverContext; ResourceBasePath = Path.Combine(ServerContext.Parameters.BaseDirectory, "Resources", "lib"); TrackingScript = new TrackingScriptProvider(serverContext); TrackingImage = new TrackingImageProvider(serverContext); }
public DataCollectEndpointModule(INAServerContext serverContext) : base("/") { ServerContext = serverContext; // Tracking Post. Intended to be used from web apps // Data: u - the source URL // Data: sid - cross domain tracking id Post("/k", async args => { await ProcessRequestDataAsync(DataRequestType.Log | DataRequestType.Hit | DataRequestType.Web); return(new Response().WithStatusCode(HttpStatusCode.OK)); }); // Custom data post. Intended for tagging with custom data // Data: tag - A short custom tag field // Data: data - A custom data field that holds a string // Data: sid - cross domain tracking id Post("/c", async args => { await ProcessRequestDataAsync(DataRequestType.Log | DataRequestType.Tag); return(new Response().WithStatusCode(HttpStatusCode.OK)); }); // Tracking image // Params: u - the source URL Get("/k.png", async args => { await ProcessRequestDataAsync(DataRequestType.Log | DataRequestType.Hit | DataRequestType.Web); // Send tracking pixel return(Response.FromStream(ServerContext.ResourceProvider.TrackingImage.CreateTrackingPixel(), "image/png")); }); // Tracking script // Params: u - the source URL Get("k.js", async args => { await ProcessRequestDataAsync(DataRequestType.Log | DataRequestType.Hit | DataRequestType.Web | DataRequestType.FetchScript); return(Response.FromStream(ServerContext.ResourceProvider.TrackingScript.CreateTrackingScript(), "application/javascript")); }); // Redirect // Params: t - The target URL Get("/r", async args => { await ProcessRequestDataAsync(DataRequestType.Log | DataRequestType.Redirect | DataRequestType.Web); var targetUrl = (string)Request.Query.t; if (targetUrl == null) { return(new Response().WithStatusCode(HttpStatusCode.BadRequest)); } // Do additional data logging return(Response.AsRedirect(targetUrl)); }); }
public DataQueryModule(INAServerContext serverContext) : base("/qr") { ServerContext = serverContext; var accessValidator = new StatelessClientValidator <NAAccessKey, NAApiAccessScope>(); this.RequiresAllClaims(new[] { accessValidator.GetAccessClaim(NAApiAccessScope.Query) }, accessValidator.GetAccessClaim(NAApiAccessScope.Admin)); // Query Log Requests // Limit is the max number of log requests to return. Default 100 Get("/log/{limit:int}", async args => { var itemLimit = args.limit as int? ?? 100; var dataLoggerService = new DataLoggerService(ServerContext); var data = await dataLoggerService.QueryRequestsAsync(itemLimit); return(Response.AsJsonNet(data)); }); // Query SessionData // Id is the ID of the session to find Get("/sessdata/{id}", async args => { var sessionStorageService = new SessionStorageService(ServerContext); var data = await sessionStorageService.GetSessionFromIdentifierAsync((string)args.id); return(Response.AsJsonNet(data)); }); // Query Tagged Requests // Tag is the tag to filter by // Limit is the max number of log requests to return Get("/tagged/{tags}/{limit:int}", async args => { var itemLimit = args.limit as int? ?? 100; var filterTags = (args.tags != null) ? ((string)args.tags).Split(',') : null; var dataLoggerService = new DataLoggerService(ServerContext); var data = await dataLoggerService.QueryTaggedRequestsAsync(itemLimit, filterTags); return(Response.AsJsonNet(data)); }); }
public KeyManagementModule(INAServerContext serverContext) : base("/km") { ServerContext = serverContext; var accessValidator = new StatelessClientValidator <NAAccessKey, NAApiAccessScope>(); this.RequiresAllClaims(new[] { accessValidator.GetAccessClaim(NAApiAccessScope.Admin) }); // API key management Post("/keys/create/{keyid}", HandleCreateKeyRequestAsync); Get("/keys/get/{keyid}", HandleGetKeyRequestAsync); Get("/keys/list", HandleListKeyRequestAsync); Delete("/keys/delete/{keyid}", HandleDeleteKeyRequestAsync); // Persist state after successful request After += ctx => { if (ctx.Response.StatusCode == HttpStatusCode.OK) { ServerContext.ServerState.Persist(); } }; }
public DataQueryDateService(INAServerContext serverContext) { ServerContext = serverContext; }
public TrackingImageProvider(INAServerContext serverContext) { ServerContext = serverContext; }
public DataLoggerService(INAServerContext serverContext) { ServerContext = serverContext; }
public TrackingScriptProvider(INAServerContext serverContext) { ServerContext = serverContext; }
public SessionStorageService(INAServerContext serverContext) { ServerContext = serverContext; }