Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Latest commit

 

History

History
94 lines (64 loc) · 3.95 KB

README.md

File metadata and controls

94 lines (64 loc) · 3.95 KB

** THIS REPO HAS BEEN ARCHIVED **

Build status Buils status

EmbedIO Extras

EmbedIO

Please star this project if you find it useful!

Additional Modules showing how to extend EmbedIO. Feel free to use these modules in your projects.

Bearer Token Module

Provides the ability to authenticate requests via a Bearer Token. This module creates a Token endpoint (at the predefined '/token' path) and all you need to do is provide a user validation delegate which authenticates the user. The module will create a JsonWebToken which can then be used by your client application for further requests. The module can check all incoming requests or a predefined set of paths. The standard header in use is the HTTP Authorization header.

You can easily add Bearer Token to your EmbedIO application using the default Basic Authorization Server Provider or writing your own by implementing IAuthorizationServerProvider interface.

The following example will attach Bearer Token to the Web server in the "/api" base route and then a WebAPI Controller using the same base route.

// Create Webserver and attach the Bearer Token Module
var server = new WebServer(url)
                .WithBearerToken("/api", "0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9eyJjbGF")
                .WithWebApi("/api", o => o.WithController<SecureController>());

Nuget installation NuGet version

PM> Install-Package EmbedIO.BearerToken

Json Server Module

Based on the JsonServer's project, with this module, you are able to simply specify a JSON file as a database and use standard REST methods to create, update, retrieve and delete records from it.

// Create Webserver and attach JsonServerModule
var server = new WebServer(url)
                .WithModule(new JsonServerModule(jsonPath: Path.Combine(WebRootPath, "database.json");               

Supported methods:

  • GET collection (http://yourhost/entity)
  • GET single (http://yourhost/entity/1 where 1 is the ID)
  • POST (http://yourhost/entity with POST body the JSON object)
  • PUT (http://yourhost/entity/1 with POST body the JSON object)
  • DELETE (http://yourhost/entity/1 where 1 is the ID)

LiteLib WebAPI

Similar to Json Server Module, but you can serve an SQLite file with all HTTP verbs using LiteLib library.

// Create Webserver and attach LiteLibModule with a LiteLib DbContext
var server = new WebServer(url)
                .WithModule(new LiteLibModule<TestDbContext>(new TestDbContext(), "/dbapi"));
                
 internal class TestDbContext : LiteDbContext
    {
        public TestDbContext()
            : base("dbase.db")
        {
            // Need to Define the tables Create  dyanmic types ?
        }

    }                
                

Supported methods:

  • GET collection (http://yourhost/entity)
  • GET single (http://yourhost/entity/1 where 1 is the ID)
  • POST (http://yourhost/entity with POST body the JSON object)
  • PUT (http://yourhost/entity/1 with POST body the JSON object)
  • DELETE (http://yourhost/entity/1 where 1 is the ID)

Markdown Static Module

The Markdown Static Module takes in a static Markdown file and converts it into HTML before returning a response. It will accept markdown/html/htm extensions (This could become middleware later).

// Create Webserver and attach Markdown Static Module
var server = new WebServer(url)
               .WithModule(new MarkdownStaticModule("/", WebRootPath));