SimpleREST.NET 0.1
A simple and minimal api framework for .net base on Express.js
Loading...
Searching...
No Matches
SimpleRestMap.cs
Go to the documentation of this file.
1using System.Text.RegularExpressions;
2using Newtonsoft.Json;
3using Uri = UriTemplate.Core;
4
5namespace SimpleRest.Api;
6
7public class SimpleRestMap
8{
9 public SimpleRestMethod Method { get; }
10
11 // public Regex Pattern { get; }
12 public ApiMiddleWare Middleware { get; }
13 public Uri.UriTemplate Pattern { get; }
14 public string Endpoint { get; }
15 public ISimpleRestRouteHandler[]? RouteHandlers { get; private set; }
16
18 string endpoint,
19 SimpleRestMethod method,
20 ApiMiddleWare middleWare,
21 ISimpleRestUriTemplateFormatter? templateHandler = null,
22 ISimpleRestRouteHandler[]? routeHandlers = null
23 )
24 {
25 Method = method;
26 string finalPattern = endpoint;
27 finalPattern = templateHandler?.GetTemplatePattern(finalPattern) ?? finalPattern;
28 Pattern = new Uri.UriTemplate(finalPattern);
29 RouteHandlers = routeHandlers;
30 Middleware = middleWare;
31 Endpoint = finalPattern;
32 }
33
34 public override string ToString()
35 {
36 return Endpoint;
37 }
38}
UriTemplate.Core Uri
ISimpleRestRouteHandler?[] RouteHandlers
SimpleRestMap(string endpoint, SimpleRestMethod method, ApiMiddleWare middleWare, ISimpleRestUriTemplateFormatter? templateHandler=null, ISimpleRestRouteHandler[]? routeHandlers=null)
delegate Task ApiMiddleWare(SimpleRestRequest request, SimpleRestResponse response)