Exemplo n.º 1
0
        /// <summary>
        /// Create a new HTTP snake server on the given root URL with the specified instance controller.
        /// To start the server, call <see cref="Run()"/>
        /// </summary>
        /// <param name="root">Root path. Should end with a slash and may contain wildcards.</param>
        /// <param name="controller">Controller determining snake action</param>
        public Server(string root, ISnakeServiceController controller)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            listener = new HttpListener();
            listener.Prefixes.Add(root);

            this.controller = controller;

            // Configure serializer
            serializerSettings = DefaultSerializerSettings;
        }
Exemplo n.º 2
0
 public void AddEndpoint(string name, ISnakeServiceController controller)
 {
     // Add a slash because .NET framework splits URLs this way
     endpoints.Add(name + "/", controller);
 }