request methods
- Annotation of existing resources;
request methods
- Annotation of existing resources;
request
const http = require("http");
const server = http.createServer((req, res) => {
const url = req.url;
if (url === "/") {
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server</title></head>");
res.write(
'<body><form action="/message" method="POST"><input type="text" value=""></form></body>'
);
res.write("</html>");
return res.end();
} else if (url === "/secondserver") {
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server Page second</title></head>");
res.write("<body><h2>Welcome to the Internet</h2></body>");
res.write("</html>");
res.end();
}
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server Page second</title></head>");
res.write("<body><h2>Welcome to the Internet</h2></body>");
res.write("</html>");
res.end();
});
server.listen(3000);
request methods
- Annotation of existing resources;
request
<?php
namespace App\Http\Controllers\Auth;
use App\Models\User;
use App\Models\Admin;
use App\Models\Blogger;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
$this->middleware('guest:admin');
$this->middleware('guest:blogger');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showAdminRegisterForm()
{
return view('auth.register', ['url' => 'admin']);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showBloggerRegisterForm()
{
return view('auth.register', ['url' => 'blogger']);
}
/**
* @param array $data
*
* @return mixed
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
/**
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function createAdmin(Request $request)
{
$this->validator($request->all())->validate();
Admin::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return redirect()->intended('login/admin');
}
/**
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function createBlogger(Request $request)
{
$this->validator($request->all())->validate();
Blogger::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return redirect()->intended('login/blogger');
}
}
request
const http = require("http");
const server = http.createServer((req, res) => {
const url = req.url;
if (url === "/") {
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server</title></head>");
res.write(
'<body><form action="/message" method="POST"><input type="text" value=""></form></body>'
);
res.write("</html>");
return res.end();
} else if (url === "/secondserver") {
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server Page second</title></head>");
res.write("<body><h2>Welcome to the Internet</h2></body>");
res.write("</html>");
res.end();
}
res.setHeader("Content-Type", "text/html");
res.write("<html>");
res.write("<head><title>Server Page second</title></head>");
res.write("<body><h2>Welcome to the Internet</h2></body>");
res.write("</html>");
res.end();
});
server.listen(3000);
request
What is an API Request?
If you specialize in apps or software development,
you must have come across the term API.
This is the short form for Application Programming Interface,
and it technically refers to a robust set of procedures,
tools, and protocols that permit the interaction between web applications.
It is an intermediary that delivers a client’s request to the server and then returns a response to the client.
APIs help software developers to streamline and shorten the application building process by eliminating frequently repeated program development processes.
In short, they help you not to keep reinventing the wheel every time you are using the same procedure to build applications.
With APIs, developers can omit some of the simple programming steps,
and thus save time and increase productivity.
However, for programmers to use APIs, they must know how to make API requests.
request
<?php
namespace App\Http\Controllers\Auth;
use App\Models\User;
use App\Models\Admin;
use App\Models\Blogger;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
$this->middleware('guest:admin');
$this->middleware('guest:blogger');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showAdminRegisterForm()
{
return view('auth.register', ['url' => 'admin']);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showBloggerRegisterForm()
{
return view('auth.register', ['url' => 'blogger']);
}
/**
* @param array $data
*
* @return mixed
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
/**
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function createAdmin(Request $request)
{
$this->validator($request->all())->validate();
Admin::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return redirect()->intended('login/admin');
}
/**
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function createBlogger(Request $request)
{
$this->validator($request->all())->validate();
Blogger::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return redirect()->intended('login/blogger');
}
}
request
What is an API Request?
If you specialize in apps or software development,
you must have come across the term API.
This is the short form for Application Programming Interface,
and it technically refers to a robust set of procedures,
tools, and protocols that permit the interaction between web applications.
It is an intermediary that delivers a client’s request to the server and then returns a response to the client.
APIs help software developers to streamline and shorten the application building process by eliminating frequently repeated program development processes.
In short, they help you not to keep reinventing the wheel every time you are using the same procedure to build applications.
With APIs, developers can omit some of the simple programming steps,
and thus save time and increase productivity.
However, for programmers to use APIs, they must know how to make API requests.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us