GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - scriptcs-contrib/scriptcs-webapi: Script pack for web api

BranchesTags
Open more actions menu

Latest commit

 

History

58 Commits
58 Commits

Folders and files

NameName
Last commit message
Last commit date
samples
samples
 
 
src/ScriptCs.WebApi
src/ScriptCs.WebApi
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
ScriptCs.WebApi.sln
ScriptCs.WebApi.sln
 
 

Repository files navigation

scriptcs-webapi

Web API Script Pack

What is it?

Makes using ASP.NET Web API's self host with scriptcs easy as cake, much easier than [this] (https://github.com/scriptcs/scriptcs-samples/tree/master/webapihost) :)

Highlights:

  • Creates a pre-configured OWIN self host with the default routes already added.
  • Supports configuring the OWIN pipeline
  • Write your controllers as scripts
  • Automatically imports common web api namespaces for you.

Getting started with Web API using the pack

  • Create a new folder for your script i.e. c:\hellowebapi and change to it.
  • Install the Web API script pack scriptcs -install -pre ScriptCs.WebApi2
  • Create a start.csx and paste the code below
using System.Dynamic;

public class TestController : ApiController
{
	public dynamic Get() {
		dynamic obj = new ExpandoObject();
		obj.message = "Hello from Web Api";
		return obj;
	}
}

var webapi = Require<WebApi>();

var server = webapi.
	Configure(typeof(TestController)).
	UseJsonOnly().
	Start("http://localhost:8080");

Console.WriteLine("Listening...");
Console.ReadLine();
server.Dispose();
  • Running as admin type scriptcs start.csx -modules mono on Windows or scriptcs start.csx on Mac/Linux to launch the app.
  • Open a browser to "http://localhost:8080/api/test";
  • That's it, your API is up!

Customizing

You can configure the OWIN host by passing in an Action<IAppBuilder> to the Configure method

var server = webapi.
	Configure(
		typeof(TestController),
		builder=> {
		  builder.Use<MyMiddleware>();
		}
	).
	Start("http://localhost:8080");

About

Script pack for web api

Resources

Readme
License
Activity
Custom properties

Stars

24 stars

Watchers

4 watching

Forks

8 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.