Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PervasiveDigital/microserver

 
 

Repository files navigation

Microserver for TinyCLR OS

Microserver is a modular server built for TinyCLR OS IoT devices.

Build Status

Socket Service

  • TCP/UDP support
  • Extendable Pipeline
  • SSL Transport Support

More Information

Web Service

  • Extendable Middleware
  • Header / Cookie Decoding
  • Forms / Files Decoding
  • Developer Execption Pages

More Information

Model-View-Controllers (MVC)

  • Controllers
  • Model Binding
  • Action Results (Content, Json, Files, Redirects)
  • Stubble View Engine
  • JSON Integration

More Information

Static File Handling

  • Storage / Resource File Serving
  • Default File Routing

More Information

Authentication

  • Basic Authentication
  • Digest Authentication

More Information

Requirements

Software: Visual Studio 2019 and GHI Electronics TinyCLR OS 2.0 or higher.
Hardware: Project was tested using SC20100S development board.

Getting Started

Work in Progress! As we encourage users to play with the samples and test programs, this project has not yet reached a stable state. See the Playground Project for an example of how to use these packages.

Getting Started

static void Main()
{
    //Attempts auto-detection of the board initializing networking and sd storage.
    Mainboard.Initialize();

    var server = new HttpServer(options =>
    {
        options.UseDeveloperExceptionPage();
        options.UseFileServer();
        options.UseMvc();
    });
    server.Start();
}
public class ExampleController : Controller
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        // called before action method
        if (filterContext.HttpContext.Request.Method != HttpMethods.Get)
        {
            filterContext.Result = new BadRequestResult();
        }
    }

    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        // called after action method
    }

    public override void OnException(ExceptionContext filterContext)
    {
        // called on action method execption
        var actionName = ControllerContext.ActionDescriptor.DisplayName;
        filterContext.Result = new ContentResult
        {
            Content = $"An error occurred in the {actionName} action.",
            ContentType = "text/plain",
            StatusCode = StatusCodes.Status500InternalServerError
        };
    }

    // Any public IActionResult method inherited from Controller is made available as an endpoint
    public IActionResult GetById(long id)
    {
        string response = "<doctype !html><html><head><title>Hello, world!</title>" +
            "<style>body { background-color: #111 }" +
            "h1 { font-size:3cm; text-align: center; color: white;}</style></head>" +
            "<body><h1>" + $"{id}" + "</h1></body></html>";

        return Content(response, "text/html");
    }
}

Branches

master - This is the branch containing the latest release - no contributions should be made directly to this branch.

develop - This is the development branch to which contributions should be proposed by contributors as pull requests. This development branch will periodically be merged to the master branch, and be released to NuGet Gallery.

Microsoft .NET Micro Framework (NETMF)

Have a look here if your looking for the orginal MicroServer built for Microsoft .NET Micro Framework (NETMF).

Contributions

Contributions to this project are always welcome. Please consider forking this project on GitHub and sending a pull request to get your improvements added to the original project.

Disclaimer

All source, documentation, instructions and products of this project are provided as-is without warranty. No liability is accepted for any damages, data loss or costs incurred by its use.

About

Microserver is a modular server built for TinyCLR OS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 98.2%
  • PowerShell 1.8%