Giter VIP home page Giter VIP logo

topshelf.nancy's Introduction

Build status

Topshelf.Nancy

A Topshelf extension providing a Nancy endpoint for your Windows service


  • Introduction
  • Installation
  • Getting Started
  • Documentation
  • Contributing
  • Copyright

Topshelf.Nancy is an extension to Topshelf that allows you to to serve content over http via Nancy. This is done by configuring a host and port for Nancy to listen onto via a NancyModule which serves your content.

Installation

Pre-requisites: The project is built in .net v4.0.

Via NuGet:

	PM> Install-Package Topshelf.Nancy

Getting Started

Once you have the package installed into your test project, a standard wire-up will look like this.

	var host = HostFactory.New(x =>
	{
	    x.UseNLog();
	    
	    x.Service<SampleService>(s =>
	    {
	        s.ConstructUsing(settings => new SampleService());
	        s.WhenStarted(service => service.Start());
	        s.WhenStopped(service => service.Stop());
	        s.WithNancyEndpoint(x, c =>
	        {
	            c.AddHost(port: 8080);
	        });
	    });
	    x.StartAutomatically();
	    x.SetServiceName("topshelf.nancy.sampleservice");
	    x.RunAsNetworkService();
	});
	
	host.Run();

A sample project is provided in the repository.

Documentation

URL Reservations

When you host a website within IIS, reserving a URL so that traffic is directed to your IIS website and not a different website on the machine is done for you. It's something you don't event think about. This is called a URL Reservation, and a new URL Reservation is added via the command netsh http add url=url user=user

The Nancy Self Host does this for you too, however netsh needs Administrator privileges. Normally Windows services run in a less permissive context (as Network Service or Local Service) so the only time to add a URL Reservation is during install as installing a service requires Administrator privileges.

If your service is running with restrictive permissions then you can specify that URL Reservations be created at install time like so.

s.WithNancyEndpoint(x, c =>
{
    c.AddHost(port: 8080);
	c.CreateUrlReservationsOnInstall();
});
	

By default any URL Reservations added will also be deleted when the service is uninstalled.

Contributing

If you find a bug, have a feature request or even want to contribute an enhancement or fix, please follow the contributing guidelines included in the repository.

Copyright

Copyright © JUST EAT PLC 2014

topshelf.nancy's People

Contributors

jaimalchohan avatar petemounce avatar jaimalchohan-justeat avatar alexander-williamson avatar anton-gogolev avatar jbuedel avatar ilikepies avatar sorenz avatar cosminonea avatar justeattech avatar

Watchers

James Cloos avatar Jaymz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.