Advertisement
Guest User

zhp

a guest
Dec 16th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.58 KB | None | 0 0
  1. const std = @import("std");
  2. const web = @import("./lib/zhp/zhp.zig").web;
  3.  
  4. pub const io_mode = .evented;
  5.  
  6. pub fn main() !void {
  7.     var app = web.Application.init(.{
  8.         .routes = &[_]web.Route{
  9.             web.Route.create("home", "/", struct {
  10.                 handler: web.RequestHandler,
  11.  
  12.                 pub fn get(self: *@This(), response: *web.HttpResponse) !void {
  13.                     try response.stream.write("HelloWorld");
  14.                 }
  15.             }),
  16.         },
  17.     });
  18.     defer app.deinit();
  19.     try app.listen("127.0.0.1", 12345);
  20.     try app.start();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement